Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This + #1222 closes #1145
This adds a new schema to
named
:commonjs: boolean | { require: boolean, exports: boolean }
The option
commonjs
accepts either a boolean or a shape withrequire
andexports
booleans within. Defaults tofalse
.The reason why the shape is allowed is to avoid having commonjs
require
statements linted. Using the boolean only option will apply to bothrequire
andexports
.The following cases of assigning exports are checked:
All declarations must be at the top level. For example, this will not be checked:
The reason why we check
Object.defineProperty
is thatbabel
will build es6 modules that way, i.e.:We need to handle those (truthy)
__esModule
properties correctly -- as in the default export will be the entiremodule.exports
if that's not set.ExportMap.for
andExportMap.parse
now take anoptions
parameter (defaults to{}
), with the keysuseCommonjsExports
andnoInterop
. Reason fornoInterop
is that plainrequire
statements should not have.default
being the entiremodule.exports
if it doesn't have a truthy__esModule
value.TODO: Configure for
babel-plugin-add-module-exports
built files. (Check formodule.exports = exports["default"]
at the end.)