-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove return outside of function as it is not es6 module compliant #3
Conversation
This file isn’t an es6 module, it’s a CommonJS module, which it is compliant with. You shouldn’t be transpiling code you didn’t write, which includes everything in node_modules, and this package. |
I agree with we should not transpile dependencies. If you need to do it (ex. creating a bundle for ES5 environment), you should use options like But let me correct a few. CJS spec does not mention to top-level return. It works because "Node.js runs Node.js modules (≒ CJS modules) with wrapper code". And, IIRC, both ES5 and ES6 language spec don't allow top-level return statements regardless of Scripts or Modules. For reference, this issue might help (too old but I think it makes sense). |
The legacy CJS spec is irrelevant; “what node supports” is what node modules require, and top level return is part of that. node modules are not a Script, they’re a function scope - and as such, top level return is already valid. Any tool that claims to support node modules but doesn’t support top level return is lying or broken. |
@ljharb |
The only module types that matter (or have for years) are node modules (commonly called CJS) or native language modules (called ESM). |
Closes inspect-js#5. Closes inspect-js#4. Closes inspect-js#3. Closes inspect-js/node-deep-equal#78. Closes es-shims/Promise.allSettled#7. Closes airbnb/js-shims#12. Relates to inspect-js/is-set#4, inspect-js/is-set#5 Addresses storybookjs/storybook#9154.
Closes inspect-js#5. Closes inspect-js#4. Closes inspect-js#3. Closes inspect-js/node-deep-equal#78. Closes es-shims/Promise.allSettled#7. Closes airbnb/js-shims#12. Relates to inspect-js/is-map#3, inspect-js/is-map#4, inspect-js/is-map#5 Addresses storybookjs/storybook#9154.
This was an enjoyable experience thank you. |
Turns out that this is caused by multiple kinds of breakage:
|
Closes inspect-js/node-deep-equal#79. Closes inspect-js/node-deep-equal#78. Closes es-shims/Promise.allSettled#7. Closes airbnb/js-shims#12. Relates to: - inspect-js/is-map#5 - inspect-js/is-map#4 - inspect-js/is-map#3 - inspect-js/is-set#5 - inspect-js/is-set#4 - storybookjs/storybook#9154.
Closes inspect-js/node-deep-equal#79. Closes inspect-js/node-deep-equal#78. Closes es-shims/Promise.allSettled#7. Closes airbnb/js-shims#12. Relates to: - inspect-js/is-map#5 - inspect-js/is-map#4 - inspect-js/is-map#3 - inspect-js/is-set#5 - inspect-js/is-set#4 - storybookjs/storybook#9154.
Since which-collection has been added to is-equal there's a lot of module dependant on is-map. According to babel/babel#1298 returns outside of function are not es6 module compliant. So I submit this PR to avoid the return.
I changed the if to avoid the negative condition. Please give me some feedback if you're unhappy with anything. Thank you.