Skip to content

Document webpack change: add script external #3772

@webpack-bot

Description

@webpack-bot

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

See pull request: webpack/webpack#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 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions