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
feat(node-profiling): Output ESM and remove Sentry deps from output #11135
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Little scared about edge cases with bundling, but lets see how it goes! |
Eghhh, I dont think this will work, but lets see. The reason is that ESM doesnt know what to do with .node modules by default whereas CJS does, and it's unclear here if the require shim uses the CJS loader or not, if it does then this will work, else it'll break with unknown module/configure loader message. Afaik what others do is they ship the equivalent of our cpu_profiler.ts or the one file in the source which actually imports the bindings as CJS, which means that 99% of the application is ESM, but then when you need to load the bindings, you force CJS so that the loader knows how to properly open it. Lets see how well this works, I'd be interested to see if it works |
We could always add another export Or alternatively output |
…etsentry#11135) - Moves Sentry deps to `dependencies` rather than `devDependencies` - Updated `package.json` exports - Updated the rollup config to mirror our other modules with the addition of the commonJs plugin - I couldn't use `createRequire` myself because Jest can't handle `import.meta` so instead I used `@rollup/plugin-esm-shim` which shims both `require` and `__dirname` in `cpu_profiler.ts` in the ESM output!
ref getsentry#9956 This is another attempt at getsentry#11033 now that getsentry#11135 has merged in.
dependencies
rather thandevDependencies
package.json
exportscreateRequire
myself because Jest can't handleimport.meta
so instead I used@rollup/plugin-esm-shim
which shims bothrequire
and__dirname
incpu_profiler.ts
in the ESM output!