Incorrect export when using ES6 export syntax
See original GitHub issueHi,
I’m currently making the switch to Babel 6 and running into the following problem, which might* be related to babelify.
Here’s my gulp-task:
let bify = browserify({
entries : './src/scripts/main.js',
standalone : 'basicContext'
})
let transformer = babelify.configure({
presets: ['es2015']
})
bify.transform(transformer)
.bundle()
.on('error', catchError)
.pipe(source(name + '.min.js'))
.pipe(buffer())
.pipe(plugins.uglify())
.on('error', catchError)
.pipe(gulp.dest('./dist'))
main.js
exports a function:
export default function(e, items, opts = {}) { … }
As I’m bundling this file as a standalone UMD module, I expected the variable basicContext
to be a function. This was the case before I updated babelify and babel. Now basicContext
is the following:
console.log(basicContext)
// {__esModule: true, default: function}
Best Tobias
- Could be cased by Babel 6, too. It’s really not easy to find the dependency casing the issue.
Issue Analytics
- State:
- Created 8 years ago
- Comments:20 (11 by maintainers)
Top Results From Across the Web
Complete Guide For ES6 Import And Export Syntax Changes
This is invalid syntax of export in ES6 export { key1: value1, key2: value2 }. To import the things we exported as named...
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 >Getting Unexpected Token Export - javascript - Stack Overflow
This error is suggesting that either webpack or babel are not working correctly, as export is only available in ES6, and those modules...
Read more >ES6 Import And Export Cheatsheet - Yogesh Chavan
This is invalid syntax of export in ES6 export { key1: value1, key2: value2 }. To import the things we exported as a...
Read more >Why is "export default var a = 1;" invalid syntax? - ES Discuss
From people.mozilla.org/~jorendorff/es6-draft.html#sec-exports, it seems that export default var a = 1; is not valid in es6. I wonder why that's the case.
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
Also, for those of you interested, this is my terrible hack to change thi behavior in my gulp pipeline:
I just wanted to follow up and say this only seems to be an issue when using Babel and requiring ES6 modules inside of ES5 modules. Just now made that realization, sorry for the noise :\