From ba1d2a6af5baefe4edf190dfb3edc18d4451c4e6 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 24 Aug 2024 16:34:00 +0530 Subject: [PATCH] docs: add `webpackIgnore` for `new URL()` --- src/content/api/module-methods.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/content/api/module-methods.mdx b/src/content/api/module-methods.mdx index d633082f2a6c..87ccd282838c 100644 --- a/src/content/api/module-methods.mdx +++ b/src/content/api/module-methods.mdx @@ -136,12 +136,16 @@ import( ```js import(/* webpackIgnore: true */ 'ignored-module.js'); + +new URL(/* webpackIgnore: true */ 'file1.css', import.meta.url); ``` ##### `webpackIgnore` Disables dynamic import parsing when set to `true`. +When using `import.meta.url`, it does not remain as-is; instead, it gets replaced based on the `baseURI`. For modules, it is replaced with `new URL("./", import.meta.url)`, and for other cases, it defaults to `document.baseURI`. This ensures that relative URLs work correctly, aligning with the base URL context. + W> Note that setting `webpackIgnore` to `true` opts out of code splitting. ##### `webpackChunkName`