You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Discourage mixing CJS and ES6 module syntax in docs #3571
Experience has shown that it is easy to fall into a trap like this:
// a.jsmodule.exports=functionfoo(){};// b.jsimportafrom'./a.js';// error, no default member found in aa.foo();
Much code has been written like this and it used to work in Webpack 2 beta, which only exacerbates the problem of spec-incompliant code like above. Webpack's doc seems to advertise the ability to mix and match different module syntax without mentioning gotchas. I suggest that Webpack should actively discourage this practice when possible, and point people to tools such as eslint-plugin-import to help fix their code.
That a.js actually is still supposed to work AFAIK...
It should only break if there is an import or export in the same file. Since it's very unlikely a user would use both export and module.exports in the same file, it's more likely to happen if there's an import and module.exports / exports.
I wonder if there's a way to make module / exports be ReferenceError, but only in the module parse goal...
Activity
[-]Discourage mixing CJS and ES6 module syntax[/-][+]Discourage mixing CJS and ES6 module syntax in docs[/+]bebraw commentedon Dec 25, 2016
Can you move this to the doc repo? Thanks.
Jessidhia commentedon Dec 25, 2016
That
a.jsactually is still supposed to work AFAIK...It should only break if there is an
importorexportin the same file. Since it's very unlikely a user would use bothexportandmodule.exportsin the same file, it's more likely to happen if there's animportandmodule.exports/exports.I wonder if there's a way to make
module/exportsbeReferenceError, but only in themoduleparse goal...