Skip to content

Commit c0038eb

Browse files
authored
docs(resolve): document module-sync in default conditionNames (#8237)
Webpack 5.107 adds "module-sync" to the default conditionNames for ESM, CJS, AMD, worker, wasm, and build-dependency resolvers, aligning with Node.js. This updates the per-dependency conditionNames defaults table in resolve.mdx and notes the alignment with Node.js's module-sync community condition. Refs: webpack/webpack#20933
1 parent a6c595e commit c0038eb

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/content/configuration/resolve.mdx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,20 @@ For example, with `target: "web"` (the default) and `mode: "production"`, the ba
330330
331331
Webpack further adjusts `conditionNames` through [`resolve.byDependency`](/configuration/resolve/#resolvebydependency) depending on how a module is imported. The `"..."` token inherits from the base conditions above.
332332
333-
| Dependency type | `conditionNames` | Used for |
334-
| --------------------------------------------------- | --------------------------------------- | ---------------------------------------------------- |
335-
| `esm`, `wasm`, `loaderImport` | `["import", "module", "..."]` | ESM `import` statements, WebAssembly, loader imports |
336-
| `commonjs`, `amd`, `loader`, `unknown`, `undefined` | `["require", "module", "..."]` | `require()` calls, AMD, and other dependency types |
337-
| `worker` | `["worker", "import", "module", "..."]` | `new Worker()` expressions |
338-
| `css-import` | `["webpack", <mode>, "style"]` | CSS `@import` statements |
339-
340-
For instance, when a file uses `import` in a project with `target: "web"` and `mode: "production"`, the final resolved conditions are `["import", "module", "webpack", "production", "browser"]`.
333+
| Dependency type | `conditionNames` | Used for |
334+
| --------------------------------------------------- | ------------------------------------------------------ | ---------------------------------------------------- |
335+
| `esm`, `wasm`, `loaderImport` | `["import", "module-sync", "module", "..."]` | ESM `import` statements, WebAssembly, loader imports |
336+
| `commonjs`, `amd`, `loader`, `unknown`, `undefined` | `["require", "module-sync", "module", "..."]` | `require()` calls, AMD, and other dependency types |
337+
| `worker` | `["worker", "import", "module-sync", "module", "..."]` | `new Worker()` expressions |
338+
| `css-import` | `["webpack", <mode>, "style"]` | CSS `@import` statements |
339+
340+
<Badge text="5.107.0+" /> `"module-sync"` is included in the default conditions
341+
to align with Node.js, which exposes the `module-sync` community condition for
342+
synchronously-loadable ESM. Packages that publish a `module-sync` export in
343+
their `package.json` are picked up automatically without additional
344+
configuration.
345+
346+
For instance, when a file uses `import` in a project with `target: "web"` and `mode: "production"`, the final resolved conditions are `["import", "module-sync", "module", "webpack", "production", "browser"]`.
341347
342348
T> The `resolveLoader` option uses different defaults for `conditionNames`: `["loader", "require", "node"]`. See [resolveLoader](#resolveloader).
343349

0 commit comments

Comments
 (0)