-
Notifications
You must be signed in to change notification settings - Fork 195
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
Support for ES6-loadable bundles? #704
Comments
I am confused about what you are asking for. We target UMD with webpack for maximum compatibility. $ does not get exported to the global namespace, but $3Dmol will for backwards compatibility. If you have a suggestion for how to change the webpack configuration to better match your workflow without breaking backwards compatibility I am happy to consider it. |
That's how it works for me now:
(you can try that too). I can use it straight from JS, and then open page right away in the browser. On the official page I see only <script> tag option for loading without additional tools. |
Glad you got it to work. As far as I can tell, ES6 export is still in development in webpack (and has been for 7 years - webpack/webpack#2933) so it isn't clear to me how to implement this in our build system and in a backward compatible manner. |
I use rollup. AFAIK (not an expert) es6 modules are not compatible with other formats (and that's the reason for such slow adoption), so this is basically +1 exporting pipeline (which produces separate 3dmol.esm.js and 3dmol.esm-min.js). I'm ready to work on PR that ships bundles if you think that's valuable. Promise not to break your existing webpack pipeline :) |
If I create another webpack config that modifies
it kinda works. I can do:
but the module doesn't seem to export anything... I don't have any more time to work on this right now, appreciate any suggestions. |
looks like. Likely it assigns to window object or smth like that. It is not much different for user compared to just <script> tag, as IDE is unlikely to track back the import. |
My rollup config is like import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
function exportPackage(name) {
return {
input: `./exports/3dmol_export.js`,
plugins: [
nodeResolve({ 'browser': true }),
commonjs(),
],
output: [{
file: `./bundles/3dmol.es6.js`,
format: 'es',
}, {
file: `./bundles/3dmol.es6.min.js`,
format: 'es',
plugins: [terser()],
},
]
}
};
export default [exportPackage(),]; with export * as $3Dmol from '<main file of the lib>'; Hope this helps |
I'm using ES6 bundles, but I do not develop with npm, just import them in a browser.
That's not extremely common scenario, but a very useful one:
and a sweet part - autosuggestions work(seems they do not work for 3dmol)I suggest serving ES6 module for 3Dmol, can help with bundling code.
Update: analysis works only partially, e.g. suggest deprecated elements, and can jump to implementation:
Support for other exported packages is usually better, but even in this state it is way more helpful compared to <script> inclusion.
The text was updated successfully, but these errors were encountered: