exportsType falsy: It's non-harmony module
exportsType "namespace": It's a harmony module, the exports is the namespace object
exportsType "default": It's a harmony module, the exports is the default exports, named exports are properties of the default export
there are too many weird modules
detect harmony modules before parsing
exports is now undefined in ESM
module.exports is now read-only in ESM and returns undefined
define is now undefined in ESM
#3917
* rename ModuleParserHelpers to ParserHelpers
- rename module and file from ModuleParserHelpers to ParserHelpers
- change imports and usages
- rename addParsedVariable to addParsedVariableToModule to add module context again
* introduce setTypeof helper to ParserHelpers
* switch setTypeof in amdplugin - use ParsersHelpers instead
* switch setTypeof in CommonJsPlugin - use ParsersHelpers instead
* switch setTypeof in SystemPlugin - use ParsersHelpers instead
* add ParserHelpers.expressionIsUnsupported method
* use ParserHelpers.expressionIsUnsupported in SystemPlugin and NodeStuffPlugin
* refactor setTypeOf to more atomic helper methods
- reduces sideeffects as parser is called outside of helper
- allows better reuse
* use ParserHelper on more pieces in CommonJsPlugin making BasicEvaluatedExpression obsolete
* switch new BasicEvaluatedExpression().setString(<somestring>).setRange(expr.range) in dependencies to ParserHelpers
* switch other new BasicEvaluatedExpression().setString(<somestring>).setRange(expr.range) to ParserHelpers
* rename wrongly named function - name anonymous functions
breaking change: compiler.parser must no longer be used. Use this instead:
``` js
compiler.plugin("compilation", function(compilation, params) {
params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
parser.plugin(/* ... */);
});
});
```
required for #2978
Previously, __filename, __dirname, and other constants were broken. This was due to
the refactor of setConstant and setModuleConstant, and the reuse of the variable name "expr"