Modify exports for use with commonjs/es6 modules
See original GitHub issueIt would be nice if you exported (test for module/module.exports as well as self) then exports against $, $$ so that they can be imported directly…
(function (context){
context.$ = $;
context.$$ = $.$;
}(
typeof module !== 'undefined' && module.exports
|| typeof self !== 'undefined' && self || this)
);
This way it can be used via cjs modules built via browserify/webpack or via es6 imports via babel as such.
import {$,$$} from 'blissfuljs';
Alternatively, if module.exports
exists, module.exports = Bliss
and assume “shy” mode.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Upgrade your Node app: From CommonJS to ES Modules
1) Prepare your code · 2) Update the package.json · 3) Convert all imports and exports · 4) Fix imports and exports ·...
Read more >Mix CommonJS and ES6 modules in same project
... Export statements: Use export keyword (e.g."export functionName") for all ES6 exports - use "module.exports" for all CommonJS exports ...
Read more >16. Modules - Exploring JS
As explained in more detail later, the structure of ES6 modules is static, you can't conditionally import or export things. That brings a...
Read more >CommonJS vs. ES Modules: Modules and Imports in NodeJS
Although at first glance it may seem like module.exports , exports and require are global, actually they are not. CommonJS wraps your code...
Read more >CommonJS vs. ES modules in Node.js - LogRocket Blog
In the browser JavaScript ecosystem, the use of JavaScript modules depends on the import and export statements; these statements load and ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FWIW, I’m currently doing a rewrite of Bliss to use ESM. Should I close this as a duplicate of #226, since once that’s complete, this will be resolved too?
@LeaVerou Closing as a duplicate makes sense to me.