Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
### :house: Internal

* refactor(otlp-exporter-base): use get*FromEnv() for otlp exporter config. [#5583](https://github.com/open-telemetry/opentelemetry-js/issues/5583) @weyert
* refactor(otlp-transformer): generate and export esm protos [#5925](https://github.com/open-telemetry/opentelemetry-js/pull/5925) @overbalance

## 0.205.0

Expand Down
3 changes: 2 additions & 1 deletion experimental/packages/otlp-transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"scripts": {
"prepublishOnly": "npm run compile",
"precompile": "lerna run version --scope @opentelemetry/otlp-transformer --include-dependencies",
"compile": "npm run protos && tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"compile": "npm run protos && tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json && npm run copy-esm-protos-to-build",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The top-level compile script actually does not call this one - the result of that is that the published package won't have the generated ESM copied to the right locations, and the CJS one will be included.

(To reproduce: run npm run compile from the top-level of the repo and inspect the experimental/otlp-transformer/build/esm/generated/root.js)

"copy-esm-protos-to-build": "cp src/generated/root.mjs build/esm/generated/root.js && cp src/generated/root.mjs build/esnext/generated/root.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using cp will not work for devs on windows, I think we need to consider an alternative here
(if something is not working for windows devs it usually comes up really quickly after merging a PR 😅)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I'll remember that in the future 😎

"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"protos": "npm run submodule && npm run protos:generate",
"protos:generate": "node ../../../scripts/generate-protos.js",
Expand Down
9 changes: 5 additions & 4 deletions scripts/generate-protos.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ function pbts(pbjsOutFile) {
return exec(path.resolve(rootBinDir, 'pbts'), [...pbtsOptions, pbjsOutFile]);
}

async function pbjs(files) {
const outFile = path.join(generatedPath, 'root.js');
async function pbjs(files, format, generatedFilename) {
const outFile = path.join(generatedPath, generatedFilename);
const pbjsOptions = [
'-t', 'static-module',
'-p', protosPath,
'-w', 'commonjs',
'-w', format,
'--null-defaults',
'-o', outFile,
];
Expand All @@ -58,6 +58,7 @@ async function pbjs(files) {
}

(async function main() {
const pbjsOut = await pbjs(protos);
const pbjsOut = await pbjs(protos, 'commonjs', 'root.js');
await pbjs(protos, 'es6', 'root.mjs');
await pbts(pbjsOut);
})();