-
Notifications
You must be signed in to change notification settings - Fork 789
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
Reference of require in esm build of base sdk packages #2464
Comments
Typically, for packages like With that option enabled, we can Notably, Node.js built-in modules already adopt the usage pattern import * as namespace from 'cjs'
console.log(namespace);
// [Module] { default: <module.exports> }
So that should match the intuitions on esm interoperation with cjs. However, with typescript, we still need the option |
As a workaround, you can enable import { defineConfig } from 'vite';
export default defineConfig({
build: {
commonjsOptions: {
transformMixedEsModules: true,
},
},
}); |
@meteorlxy Thanks for the suggestion. However, the problem in this issue is that the esm builds officially published can not be imported with Node.js built-in ECMAScript modules support too, that is, the ESM build product is not a valid esm build product. |
Yes, I also noticed this problem yesterday. However, I don't think it's a good idea to enable I'd prefer to replace |
@meteorlxy I don't quite get a point of the "contagious" problem. As the option is just about the import behavior in enabled files, but not export behavior. Would you mind sharing any links about the "contagious" problem so that we can reach the same understanding of the options? |
Do you have an alternative suggestion if not esmoduleinterop?
@meteorlxy provided an example in #2467. Here it is: https://github.com/meteorlxy/esmoduleinterop-issue I would definitely prefer not to require our customers to enable es module interop if they don't want to, but providing a broken ESM build is also not acceptable. Is lodash.merge the only broken dependency? It is only used for configuration merging so it should be simple to either find an alternative or write it ourselves. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
I'm also using vite and seeing this issue. Neither |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This is still an issue. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
The fix should have been released in v1.1.0. |
Please answer these questions before submitting a bug report.
What version of OpenTelemetry are you using?
0.25.0
Please provide the code you used to setup the OpenTelemetry SDK
What did you do?
Build the file with vite or rollup in esm mode (commonjs is not enabled) and access in browser.
> vite
What did you expect to see?
The script ran without exceptions.
What did you see instead?
Uncaught ReferenceError: require is not defined
Additional context
The text was updated successfully, but these errors were encountered: