-
Notifications
You must be signed in to change notification settings - Fork 60
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
Switch to ESM #110
Comments
Just to clarify here... there's two ESM related things that are possible here:
Which of these were you describing with this ticket? |
I'm trying to buld Google cloud functions with webpack with enabled ESM. But external modules added with webpack-node-externals are commonjs by default and webpack compiles them as: /***/ "pino":
/*!***********************!*\
!*** external "pino" ***!
\***********************/
/***/ ((module) => {
module.exports = require("pino");
/***/ }), As you can see webpack is dumb and uses |
Used webpack-node-externals option |
|
We'd like to use some CJS dependencies (e.g. lodash) and some ESM-only ones (like d3). Now my issue is that neither of the
and with
Without |
@cbix importType: function( request ) {
if( request === '@errorx666/query' ) {
return `module ${request}`;
} else {
return `node-commonjs ${request}`;
}
} More properly, the code should probably check package.json for type: module. |
Change the module from CommonJS to ECMAScript Module (ESM). Some JS Frameworks support ESM now and importing CommonJS modules may get complicated.
The text was updated successfully, but these errors were encountered: