Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): fix unreachable @opentelemetry/api/experimental entry #4446

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ All notable changes to this project will be documented in this file.
## Unreleased

* feat(api): add SugaredTracer for functions not defined in the spec

## Unreleased
* fix(api): fix unreachable @opentelemetry/api/experimental entry [#4446](https://github.com/open-telemetry/opentelemetry-js/pull/4446) @legendecas

## 1.7.0

Expand Down
8 changes: 4 additions & 4 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"default": "./build/src/index.js"
},
"./experimental": {
"module": "./build/esm/experimental.js",
"esnext": "./build/esnext/experimental.js",
"types": "./build/src/experimental.d.ts",
"default": "./build/src/experimental.js"
"module": "./build/esm/experimental/index.js",
"esnext": "./build/esnext/experimental/index.js",
"types": "./build/src/experimental/index.d.ts",
"default": "./build/src/experimental/index.js"
}
},
"repository": "open-telemetry/opentelemetry-js",
Expand Down
23 changes: 20 additions & 3 deletions eslint.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module.exports = {
"node",
"prettier"
],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
extends: ["eslint:recommended", "plugin:prettier/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
"project": "./tsconfig.json"
"project": null,
},
rules: {
"quotes": ["error", "single", { "avoidEscape": true }],
Expand All @@ -29,6 +29,11 @@ module.exports = {
overrides: [
{
files: ['*.ts'],
// Enable typescript-eslint for ts files.
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
parserOptions: {
"project": "./tsconfig.json"
},
rules: {
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-this-alias": "off",
Expand All @@ -50,21 +55,33 @@ module.exports = {
}
}],
"@typescript-eslint/no-shadow": ["warn"],
"prefer-rest-params": "off",
}
},
{
files: ["test/**/*.ts"],
// Enable typescript-eslint for ts files.
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
parserOptions: {
"project": "./tsconfig.json"
},
rules: {
"no-empty": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/ban-types": ["warn", {
"types": {
"Function": null,
}
}],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-shadow": ["off"],
"@typescript-eslint/no-floating-promises": ["off"],
"@typescript-eslint/no-non-null-assertion": ["off"],
"@typescript-eslint/explicit-module-boundary-types": ["off"]
"@typescript-eslint/explicit-module-boundary-types": ["off"],
"prefer-rest-params": "off",
}
}
]
Expand Down
24 changes: 24 additions & 0 deletions integration-tests/api/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = {
env: {
mocha: true,
commonjs: true,
node: true,
browser: true,
},
...require('../../eslint.base.js'),
};
10 changes: 10 additions & 0 deletions integration-tests/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# `opentelemetry/integration-tests-api`

This is an integration test suite for `@opentelemetry/api` that verifies the
api package works as expected when being imported.

## Test

```sh
npm run test
```
40 changes: 40 additions & 0 deletions integration-tests/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@opentelemetry/integration-tests-api",
"version": "1.20.0",
pichlermarc marked this conversation as resolved.
Show resolved Hide resolved
"private": true,
"publishConfig": {
"access": "restricted"
},
"description": "Verifies @opentelemetry/api in integration tests",
"author": "OpenTelemetry Authors",
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/integration-tests/api",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/open-telemetry/opentelemetry-js.git"
},
"bugs": {
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"engines": {
"node": ">=14"
},
"scripts": {
"compile": "cross-var lerna run version --scope $npm_package_name --include-dependencies",
"pretest": "npm run compile",
"test": "nyc mocha test/**/*.test.js",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"lint": "eslint . --ext .js",
"lint:fix": "eslint . --ext .js --fix"
},
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@types/mocha": "9.1.1",
"@types/node": "18.6.5",
"codecov": "3.8.3",
"cross-var": "1.1.0",
"lerna": "6.6.2",
"mocha": "10.0.0",
"nyc": "15.1.0"
}
}
48 changes: 48 additions & 0 deletions integration-tests/api/test/api-entries.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const assert = require('assert');

// TypeScript v4.4.4 doesn't support `node16` or `nodenext` in
// [Module Resolution](https://www.typescriptlang.org/tsconfig#moduleResolution)
// which is required for typescript to resolve the `package.json#exports`
// entries.
// Additionally, using `node16` or `nodenext` in `tsconfig.json#moduleResolution`
// requires the TypeScript to generate ESModule outputs. This is a breaking
// change for CJS users.
// So we have to use plain JavaScript to verity the `package.json#exports` here.

describe('@opentelemetry/api entries', () => {
it('should import root entry', async () => {
const mod = await import('@opentelemetry/api');
assert.ok(mod.trace != null);
});

it('should require root entry', () => {
const mod = require('@opentelemetry/api');
assert.ok(mod.trace != null);
});

it('should import experimental entry', async () => {
const mod = await import('@opentelemetry/api/experimental');
assert.ok(mod.wrapTracer != null);
});

it('should require experimental entry', () => {
const mod = require('@opentelemetry/api/experimental');
assert.ok(mod.wrapTracer != null);
});
});