Dealing with ES6 export
See original GitHub issue/* foobar.js */
// ES6 export
const foobar = {
foo: 'bar'
}
export default foobar;
// is equivalent to
module.exports = {
default: foobar
}
/* foobar-log.js */
console.log(foobar);
So if I import foobar-log.js
with imports-loader
import 'imports?foobar=./foobar!./foobar-log'
It gives object with default. It seems there’re no way toget just { foo: bar }
.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:10 (1 by maintainers)
Top Results From Across the Web
ES6 Modules and How to Use Import and Export in JavaScript
You can export members one by one. What's not exported won't be available directly outside the module: export const myNumbers = [ ...
Read more >export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the ......
Read more >ES6 | Import and Export - GeeksforGeeks
ES6 | Import and Export · Example 1: Create a file named export.js and write the below code in that file. export let...
Read more >ES6 Import And Export Cheatsheet - Yogesh Chavan
In ES6, data declared in one file is not accessible to another file until it is exported from that file and imported into...
Read more >16. Modules - Exploring JS
16.3 The basics of ES6 modules #. There are two kinds of exports: named exports (several per module) and default exports (one per...
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 FreeTop 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
Top GitHub Comments
@SpaceK33z , #35 allows something like
imports?foobar.default=foobar
which would result infoobar.default = require('foobar')
, but what we want in this case is something likeimports?foobar=foobar.default
to result invar foobar = require('foobar').default
, since the ES6 transpilation will end up nesting the default export of the module under thedefault
property offoobar
’s exported object.I tried to do something like that with v0.7.0 without luck. That makes sense though, considering
.
is an allowed character in file names, so there’s no way to know whether it’s part of the filename or property notation.Having an easy way to import default exports and/or named exports would be nice.
@getsnoopy try this e.g.
imports-loader?{default:Auth0Lock}=auth0-lock!angular-lock
using a ES2015 destructor will solve the problem