-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(chore): fix main file location, ensure compatibility with nodejs #842
Conversation
The current setup uses implicit default main file `index.js` which uses es6 native module `import` syntax, and directly loads from source file (`lib` folder) which uses native module `import` syntax too. The whole setup bypasses `dist` file prepared by rollup. The reason that this setup still works in webpack, is webpack supports es6 native module `import` syntax. We don't have the luck if we use the main file in nodejs or browser environments directly (both currently do not support `import` syntax by default).
What is your setup / which setups would you like to support? |
The linked issue above uses aureli-cli which uses a requirejs based build, it supports normal commonjs/umd/amd code which is shipped by most npm packages. The current setup stops nodejs with a simple |
I guess aurelia is using browserify to consume libraries and bundle things for the browser. Did you consider adding the respective |
The alternative is to use the workaround you provide. |
Not browserify, aurelia uses amodra-trace currently which translate cjs into amd module. I think it's a common practice to ship npm package in a format which is understandable by nodejs. After all, npm package is designed to be consumed by nodejs. This PR would not affect webpack, just reduce its effert in dealing with |
I understand, this is not a big issue for using bpmn in aurelia. After all, it's your call whether to make it smoother to nodejs env and other bundlering tool other than webpack. |
We came from CommonJS and switched to ES modules for reasons such as smaller bundle sizes / tree shaking. My guess is that eventually, all decent bundlers and NodeJS will understand ES modules, as it is the new standard for JavaScript modules. Before we reach this point, people that are forced into AMD / cjs environments with no ability to control the actual transpilation should resort to the workaround you mentioned:
|
Thx for the reasoning. Appreciated. |
The current setup uses implicit default main file
index.js
which uses es6 native moduleimport
syntax, and directly loads from source file (lib
folder) which uses native moduleimport
syntax too.The whole setup bypasses
dist
file prepared by rollup.The reason that this setup still works in webpack, is webpack supports es6 native module
import
syntax. We don't have the luck if we use the main file in nodejs or browser environments directly (both currently do not supportimport
syntax by default).