webpack.js.org icon indicating copy to clipboard operation
webpack.js.org copied to clipboard

Document webpack change: add script external

Open webpack-bot opened this issue 5 years ago • 5 comments

A pull request by @sokra was merged and maintainers requested a documentation change.

See pull request: https://github.com/webpack/webpack/pull/10992


  • move script loading into separate runtime module
  • attach to existing script tags
  • add script external
  • change defaults of ModuleFederationPlugin to var library and script remoteType
  • allow using empty entry in config
  • add module-federation example

What kind of change does this PR introduce? feature

Did you add tests for your changes? yes

Does this PR introduce a breaking change? yes

What needs to be documented once your changes are merged?

  • entry: {} is now a support option for an build without configured entrypoint. e. g. when using only entrypoints generated by plugins.
  • When loading things with script tags, the runtime will now try to find an existing script tag that matches the src or has a secific data-webpack attribute.
    • For chunk loadng data-webpack="chunk-[chunkId]", for script external data-webpack="[global]"
  • When loadng things with script tags, the runtime will now remove the script tag once the script has been loaded.

New script external:

  • The new script externalType will load a script tag and use a global afterwarts.
  • Syntax: external: { xxx: ["http://example.com/script.js", "global", "property", "property"] } (properties are optional)
  • Shortcut syntax: external: { xxx: "global@http://example.com/script.js" }
  • Any url is allowed. Public path will not be added.
  • Options like output.chunkLoadTimeout output.crossOriginLoading output.jsonpScriptType will apply to these scripts too.

Module Federation:

  • The default for ModuleFederationPlugin.remoteType is now: ModuleFederationPlugin.library ? ModuleFederationPlugin.library.type : "script"
  • The default for the ModuleFederationPlugin.library is now { type: "var", name: name }

webpack-bot avatar Jun 05 '20 01:06 webpack-bot

Gdy

pooomhfhfgsdfddf avatar Jun 05 '20 05:06 pooomhfhfgsdfddf

Output.chunkLoadTimeout

pooomhfhfgsdfddf avatar Jun 05 '20 05:06 pooomhfhfgsdfddf

Duplicate of `

pooomhfhfgsdfddf avatar Jun 05 '20 05:06 pooomhfhfgsdfddf

@chenxsan Can we close it or something need more docs?

alexander-akait avatar Sep 07 '20 15:09 alexander-akait

@evilebottnawi The Module Federation part is not documented yet. It's a kinda advanced topic, would be great if someone familiar with it can help document it. Also it's an old issue, things might have changed.

chenxsan avatar Sep 07 '20 15:09 chenxsan