question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modify exports for use with commonjs/es6 modules

See original GitHub issue

It 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:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
LeaVeroucommented, Oct 21, 2020

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?

1reaction
matthiaskcommented, Oct 21, 2020

@LeaVerou Closing as a duplicate makes sense to me.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found