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
This is a nice One! i will write about that in my book thanks for supplying this but let me show you a importent code style change when you code esModules
exports.new=function(){};// Wrong Really bad!
'use strict'// Only needed in the first file but is here for educationconstnew=function(){};// This already errors even in es5exports.new=new;// Good thing we assign to exports a already defined var
Welcome to Node.js v17.1.0.
Type ".help" for more information.
> const new = ''
const new = ''
^^^
Uncaught SyntaxError: Unexpected token 'new'
>
this error is also already correctly catched by eslint and typescript so this can be closed its out of scope for lebab to run such checks before the main transform applys while i think it would be nice to add something that changes
exports.new=function(){};
to
constnew=function(){};exports.new=new;
and use that as pre transform so that people could check if that cjs code runs before they apply the import/export transform
this works in es5
this fails in es6
cos
new
is a reserved keywordonly solution is to rename the export/import
lebab should at least show a warning
The text was updated successfully, but these errors were encountered: