Skip to content

Commit ee4cbf4

Browse files
authored
docs: add sourceImport experiment feature
1 parent 78494e5 commit ee4cbf4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/content/configuration/experiments.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Available options:
2929
- [`futureDefaults`](#experimentsfuturedefaults)
3030
- [`lazyCompilation`](#experimentslazycompilation)
3131
- [`outputModule`](#experimentsoutputmodule)
32+
- [`sourceImport`](#experimentssourceimport)
3233
- `syncWebAssembly`: Support the old WebAssembly like in webpack 4.
3334
- `layers`: Enable module and chunk layers, removed and works without additional options since `5.102.0`.
3435
- `topLevelAwait`: Transforms a module into an `async` module when an `await` is used at the top level. Starting from webpack version `5.83.0` (however, in versions prior to that, you can enable it by setting `experiments.topLevelAwait` to `true`), this feature is enabled by default, removed and works without additional options since `5.102.0`.
@@ -43,6 +44,7 @@ export default {
4344
buildHttp: true,
4445
lazyCompilation: true,
4546
outputModule: true,
47+
sourceImport: true,
4648
syncWebAssembly: true,
4749
topLevelAwait: true,
4850
},
@@ -278,6 +280,29 @@ It's suggested to put the magic comment after the `from` keyword. Other position
278280

279281
Putting the magic comment after the `import` keyword is incompatible with the filesystem cache.
280282

283+
### experiments.sourceImport
284+
285+
Enable support for the tc39 proposal [Source Phase Imports](https://github.com/tc39/proposal-source-phase-imports).
286+
287+
- Type: `boolean`
288+
289+
This feature enables importing modules at the source phase via `import source ...` and `import.source(...)`.
290+
291+
<Badge text="5.106.0+" />
292+
293+
{/* eslint-skip */}
294+
295+
```js
296+
// webpack.config.js
297+
export default {
298+
// ...
299+
experiments: {
300+
asyncWebAssembly: true,
301+
sourceImport: true,
302+
},
303+
};
304+
```
305+
281306
{/* eslint-skip */}
282307

283308
```js

0 commit comments

Comments
 (0)