Skip to content

Conversation

@sokra
Copy link
Member

@sokra sokra commented Oct 8, 2019

This PR allows to run webpack without runtime in some cases.

  • remove items from runtime when unneeded
  • add requireScope RuntimeGlobal
  • Deprecate MainTemplate, ChunkTemplate, ModuleTemplate
    • move some hooks to CompatRuntimeModule
    • move logic and hooks to JavascriptModulesPlugin
  • terser defaults inherit ecma version
  • refactor Module.source() and Module.getRuntimeRequirements() into Module.codeGeneration()
  • add code generation phase to Compilation
  • add output.iife options to remove iife wrapper
  • add experiments.outputModule which enables output.module
  • add output.module which sets defaults to output.iife: false, output.libraryTarget: "module", output.jsonpScriptType: "module", terserOptions.module: true
  • add output.libraryTarget: "module" (not yet implemented)
  • add output.module example
  • improve runtime requirements needed by ConcatenatedModule
  • add entry inlining, which inlines entry module code into runtime scope (only when safe)
  • make whole bundle strict when all modules are strict
  • remove "use strict" from runtime things for bundle size reasons

What kind of change does this PR introduce?
refactoring, feature

Did you add tests for your changes?
yes

Does this PR introduce a breaking change?
maybe, but compat-layer added

What needs to be documented once your changes are merged?

  • add output.iife options to remove iife wrapper
  • add experiments.outputModule which enabled output.module and output.libraryTarget: "module" (and also enabled them by default)
  • add output.module which sets defaults to output.iife: false, output.libraryTarget: "module", output.jsonpScriptType: "module", terserOptions.module: true
  • add output.libraryTarget: "module" (not yet implemented)

sokra added 9 commits October 8, 2019 23:46
remove some hooks from MainTemplate, move some hooks to CompatRuntimeModule
add requireScope RuntimeGlobal
move logic and hooks to JavascriptModulesPlugin
…ule.codeGeneration

add code generation phase to Compilation
add `output.iife` options to remove iife wrapper
add `experiments.outputModule` which enabled `output.module`
add `output.module` which sets defaults to `output.iife: false`, `output.libraryTarget: "module"`, `output.jsonpScriptType: "module"`, `terserOptions.module: true`
add `output.module` example
improve runtime requirements needed by ConcatenatedModule
add entry inlining, which inlines entry module code into runtime scope (only when safe)
make whole bundle strict when all modules are strict
@webpack-bot
Copy link
Contributor

webpack-bot commented Oct 8, 2019

For maintainers only:

  • This need to be documented (issue in webpack/webpack.js.org will be filed when merged)

@sokra sokra force-pushed the feature/runtime-less branch from 509d36a to f08c981 Compare October 9, 2019 07:34
@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@sokra sokra merged commit 08dd5ad into next Oct 10, 2019
@sokra sokra deleted the feature/runtime-less branch October 10, 2019 12:28
@webpack-bot
Copy link
Contributor

I've created an issue to document this in webpack/webpack.js.org.

module: options.output.module,
ecma:
options.output.ecmaVersion > 2000
? options.output.ecmaVersion - 2009
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options.output.ecmaVersion: 2009 doesn't work as expected and generate invalid ecma version. I think will be great disable usage 20* option for ecmaVersion:

  • better schema validation
  • some developers can do mistake like 2029 or 20029
  • new version of ecma may not be released every year

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema should handle this

"ecmaVersion": {
"description": "The maximum EcmaScript version of the webpack generated code (doesn't include input source code from modules).",
"anyOf": [
{
"enum": [5]
},
{
"type": "number",
"minimum": 2015
}
]
},

The official ecma version naming is by year. it's ES3 -> ES5 -> ES2015 -> ES2016 -> ...

  • some developers can do mistake like 2029 or 20029

we could add a maximum of i. e. 3000 to catch 20029.
2029 is a valid (not yet released) ecma version, so this seem fine to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants