@intlayer/webpack 9.3.0 → 9.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,27 +47,27 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
47
47
 
48
48
  ## Keys benefits of Intlayer:
49
49
 
50
- | Feature | Description |
51
- | --------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
53
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
54
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
55
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.jpg?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
56
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
57
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
58
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
59
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
60
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
61
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
62
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
63
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
64
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
65
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
66
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
67
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
68
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
69
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) |
70
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
50
+ | Feature | Description |
51
+ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
53
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
54
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
55
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.jpg?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
56
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
57
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
58
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
59
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
60
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
61
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
62
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
63
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
64
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
65
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
66
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
67
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
68
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
69
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
70
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
71
71
 
72
72
  ---
73
73
 
@@ -162,7 +162,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
162
162
  <li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
163
163
  <li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
164
164
  <ul>
165
- <li><a href="https://intlayer.org/doc/concept/content/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
165
+ <li><a href="https://intlayer.org/doc/concept/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
166
166
  <li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
167
167
  <li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
168
168
  <li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
@@ -183,7 +183,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
183
183
  <ul>
184
184
  <li><a href="https://intlayer.org/doc/environment/nextjs/15" rel=''>Next.js 15</a></li>
185
185
  <li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
186
- <li><a href="https://intlayer.org/doc/environment/nextjs/next-with-Page-Router" rel=''>Next.js Page Router</a></li>
186
+ <li><a href="https://intlayer.org/doc/environment/nextjs/next-with-page-router" rel=''>Next.js Page Router</a></li>
187
187
  <li><a href="https://intlayer.org/doc/environment/nextjs/compiler" rel=''>Next.js using Compiler</a></li>
188
188
  </ul>
189
189
  </li>
@@ -212,7 +212,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
212
212
  <li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
213
213
  <li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
214
214
  <li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
215
- <li><a href="https://intlayer.org/doc/environment/vite-and-nuxt" rel=''>Vite + Nuxt</a></li>
215
+ <li><a href="https://intlayer.org/doc/environment/nuxt-and-vue" rel=''>Vite + Nuxt</a></li>
216
216
  <li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
217
217
  <li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
218
218
  <li>
@@ -19,11 +19,10 @@ var __copyProps = (to, from, except, desc) => {
19
19
  }
20
20
  return to;
21
21
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
23
23
  value: mod,
24
24
  enumerable: true
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
-
29
28
  exports.__toESM = __toESM;
@@ -1 +1 @@
1
- {"version":3,"file":"getEntries.cjs","names":[],"sources":["../../src/getEntries.ts"],"sourcesContent":["import { listDictionaries } from '@intlayer/engine/listDictionaries';\nimport { getPathHash } from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { EntryObject } from 'webpack';\n\nexport const getEntries = async (\n configuration: IntlayerConfig\n): Promise<EntryObject> => {\n const files = await listDictionaries(configuration);\n\n return files.reduce((obj, el) => {\n const hash = getPathHash(el);\n\n obj[`intlayer-content/${hash}`] = {\n import: el,\n dependOn: undefined,\n };\n\n return obj;\n }, {} as EntryObject);\n};\n"],"mappings":";;;;;AAKA,MAAa,aAAa,OACxB,kBACyB;CAGzB,QAAO,8DAF8B,aAAa,EAEtC,CAAC,QAAQ,KAAK,OAAO;EAC/B,MAAM,+CAAmB,EAAE;EAE3B,IAAI,oBAAoB,UAAU;GAChC,QAAQ;GACR,UAAU;EACZ;EAEA,OAAO;CACT,GAAG,CAAC,CAAgB;AACtB"}
1
+ {"version":3,"file":"getEntries.cjs","names":["listDictionaries","getPathHash"],"sources":["../../src/getEntries.ts"],"sourcesContent":["import { listDictionaries } from '@intlayer/engine/listDictionaries';\nimport { getPathHash } from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { EntryObject } from 'webpack';\n\nexport const getEntries = async (\n configuration: IntlayerConfig\n): Promise<EntryObject> => {\n const files = await listDictionaries(configuration);\n\n return files.reduce((obj, el) => {\n const hash = getPathHash(el);\n\n obj[`intlayer-content/${hash}`] = {\n import: el,\n dependOn: undefined,\n };\n\n return obj;\n }, {} as EntryObject);\n};\n"],"mappings":";;;;;AAKA,MAAa,aAAa,OACxB,kBACyB;CAGzB,QAAO,UAFaA,oDAAiB,aAAa,EAEtC,CAAC,QAAQ,KAAK,OAAO;EAC/B,MAAM,WAAOC,oCAAY,EAAE;EAE3B,IAAI,oBAAoB,UAAU;GAChC,QAAQ;GACR,UAAU;EACZ;EAEA,OAAO;CACT,GAAG,CAAC,CAAgB;AACtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["isESModule","path"],"sources":["../../src/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config/utils';\n\n/**\n * Set the __dirname global variable to make the config work in both ESM and CJS environments\n */\nexport const defineDirname = () => {\n const filename = isESModule\n ? fileURLToPath(import.meta.url)\n : require('node:url').pathToFileURL(__filename).toString();\n\n globalThis.__filename = globalThis.__filename ?? filename;\n globalThis.__dirname = globalThis.__dirname ?? path.dirname(__filename);\n};\n"],"mappings":";;;;;;;;;;;AAOA,MAAa,sBAAsB;CACjC,MAAM,WAAWA,6GACgB,IAC7B,QAAQ,UAAU,CAAC,CAAC,cAAc,UAAU,CAAC,CAAC,SAAS;CAE3D,WAAW,aAAa,WAAW,cAAc;CACjD,WAAW,YAAY,WAAW,aAAaC,kBAAK,QAAQ,UAAU;AACxE"}
1
+ {"version":3,"file":"utils.cjs","names":["isESModule","fileURLToPath","path"],"sources":["../../src/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config/utils';\n\n/**\n * Set the __dirname global variable to make the config work in both ESM and CJS environments\n */\nexport const defineDirname = () => {\n const filename = isESModule\n ? fileURLToPath(import.meta.url)\n : require('node:url').pathToFileURL(__filename).toString();\n\n globalThis.__filename = globalThis.__filename ?? filename;\n globalThis.__dirname = globalThis.__dirname ?? path.dirname(__filename);\n};\n"],"mappings":";;;;;;;;;;;AAOA,MAAa,sBAAsB;CACjC,MAAM,WAAWA,wCACbC,qEAA6B,IAC7B,QAAQ,UAAU,CAAC,CAAC,cAAc,UAAU,CAAC,CAAC,SAAS;CAE3D,WAAW,aAAa,WAAW,cAAc;CACjD,WAAW,YAAY,WAAW,aAAaC,kBAAK,QAAQ,UAAU;AACxE"}
@@ -9,6 +9,29 @@ let _intlayer_engine_build = require("@intlayer/engine/build");
9
9
  let _intlayer_engine_watcher = require("@intlayer/engine/watcher");
10
10
 
11
11
  //#region src/webpack-plugin.ts
12
+ /**
13
+ * Narrows an entry of `compiler.options.plugins` to a `DefinePlugin` instance.
14
+ *
15
+ * @param plugin - Any entry of the webpack `plugins` array (may be a function,
16
+ * `undefined` or `false` when the host config uses conditional
17
+ * plugin lists).
18
+ */
19
+ const isDefinePlugin = (plugin) => typeof plugin === "object" && plugin !== null && plugin.constructor?.name === "DefinePlugin";
20
+ /**
21
+ * Checks whether the host bundler already replaces the whole `process.env`
22
+ * expression through its own `DefinePlugin`.
23
+ *
24
+ * Create React App defines `process.env` as an object literal holding its
25
+ * `REACT_APP_*` variables. Declaring a second, differently-valued `process.env`
26
+ * makes webpack emit `Conflicting values for 'process.env'`, which CRA
27
+ * escalates to a build failure whenever `process.env.CI` is set (the default on
28
+ * CI servers). When the host already provides that replacement, every
29
+ * `process.env.*` read resolves against its object literal instead of a bare
30
+ * `process`, so the catch-all define is redundant and can be skipped.
31
+ *
32
+ * @param compiler - The webpack compiler the Intlayer plugin is applied to.
33
+ */
34
+ const getHasHostProcessEnvDefine = (compiler) => (compiler.options.plugins ?? []).some((plugin) => isDefinePlugin(plugin) && "process.env" in (plugin.definitions ?? {}));
12
35
  var IntlayerPlugin = class {
13
36
  isWatching = false;
14
37
  configuration;
@@ -42,7 +65,7 @@ var IntlayerPlugin = class {
42
65
  };
43
66
  }
44
67
  new webpack.DefinePlugin({
45
- "process.env": "({})",
68
+ ...getHasHostProcessEnvDefine(compiler) ? {} : { "process.env": "({})" },
46
69
  ...env
47
70
  }).apply(compiler);
48
71
  if (!isBuild && this.configuration.content.watch) await (0, _intlayer_engine_watcher.watch)({ configuration: this.configuration });
@@ -1 +1 @@
1
- {"version":3,"file":"webpack-plugin.cjs","names":["BLUE"],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { BLUE } from '@intlayer/config/colors';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { watch } from '@intlayer/engine/watcher';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Compiler } from 'webpack';\n\n// Watch mode or on time build\nexport class IntlayerPlugin {\n private isWatching = false; // Flag to ensure we only start the watcher after the first build\n private configuration;\n\n constructor(configuration?: IntlayerConfig) {\n this.configuration = configuration ?? getConfiguration();\n }\n\n async apply(compiler: Compiler): Promise<void> {\n const { webpack } = compiler;\n\n const isBuild = compiler.options.mode !== 'development';\n\n const appLogger = getAppLogger(this.configuration);\n\n // Register the dictionary preparation tap *synchronously*, before any\n // `await` below. webpack does not await a plugin's async `apply`, so any\n // hook tapped after an `await` (e.g. after `watch()`) may register too late\n // — after `beforeCompile` has already fired — leaving the `.intlayer`\n // dictionaries entry unbuilt when module resolution starts and breaking the\n // build with `Can't resolve '@intlayer/dictionaries-entry'`. Tapping here\n // guarantees the entry is prepared before compilation begins.\n compiler.hooks.beforeCompile.tapPromise('IntlayerPlugin', async () => {\n if (!this.isWatching) {\n try {\n await prepareIntlayer(this.configuration);\n this.isWatching = true;\n } catch (error) {\n appLogger(`Error in IntlayerPlugin: ${error}`, {\n level: 'error',\n });\n }\n }\n });\n\n const wrapKey = (key: string) => `process.env.${key}`;\n const wrapValue = (value: string) => `\"${value}\"`;\n\n // Specific `process.env.<KEY>` defines. webpack's DefinePlugin replaces both\n // the dot- and bracket-notation reads of a defined key, and — crucially —\n // folds them at *parse* time, which lets it dead-code-eliminate the guarded\n // dynamic `import()` chunks (e.g. the HTML/markdown renderers) for unused\n // node types. The config flags are emitted in every mode so routing/editor\n // behaviour is correct in dev too; the dictionary scan (used to prune node\n // types) only runs for production builds.\n let env: Record<string, string> = {\n ...getConfigEnvVars(this.configuration, wrapKey, wrapValue),\n };\n\n if (isBuild) {\n const dictionaries = getDictionaries(this.configuration);\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out plugins:',\n unusedNodeTypes.map((key) => colorize(key, BLUE)).join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n env = {\n ...env,\n\n // Tree shaking based on unused node types\n ...formatNodeTypeToEnvVar(unusedNodeTypes, wrapKey, wrapValue),\n\n // Tree shaking the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n wrapKey,\n wrapValue\n ),\n };\n }\n\n new webpack.DefinePlugin({\n // Catch-all so that any `process.env.*` read NOT folded by the specific\n // keys below still resolves to `undefined` instead of dereferencing a\n // bare `process`, which is not defined in browser bundles (e.g. Angular)\n // and throws `process is not defined`. This covers in-use node types\n // (never emitted as \"false\"), the dictionary selector when present, and\n // every read in development where the dictionary scan is skipped. Specific\n // keys (below) and host bundler defines (e.g. `process.env.NODE_ENV`) take\n // precedence over this object, so chunk-level tree shaking is preserved.\n 'process.env': '({})',\n ...env,\n }).apply(compiler);\n\n // Only watch content declarations for the dev server. A production build is\n // a one-off compilation: starting a file watcher there serves no purpose and\n // keeps a live `fsevents`/chokidar stream open for the whole build.\n if (!isBuild && this.configuration.content.watch) {\n // Start watching (assuming watch is also async)\n await watch({ configuration: this.configuration });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAmBA,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,aAAa;CACrB,AAAQ;CAER,YAAY,eAAgC;EAC1C,KAAK,gBAAgB,6DAAkC;CACzD;CAEA,MAAM,MAAM,UAAmC;EAC7C,MAAM,EAAE,YAAY;EAEpB,MAAM,UAAU,SAAS,QAAQ,SAAS;EAE1C,MAAM,sDAAyB,KAAK,aAAa;EASjD,SAAS,MAAM,cAAc,WAAW,kBAAkB,YAAY;GACpE,IAAI,CAAC,KAAK,YACR,IAAI;IACF,kDAAsB,KAAK,aAAa;IACxC,KAAK,aAAa;GACpB,SAAS,OAAO;IACd,UAAU,4BAA4B,SAAS,EAC7C,OAAO,QACT,CAAC;GACH;EAEJ,CAAC;EAED,MAAM,WAAW,QAAgB,eAAe;EAChD,MAAM,aAAa,UAAkB,IAAI,MAAM;EAS/C,IAAI,MAA8B,EAChC,kDAAoB,KAAK,eAAe,SAAS,SAAS,EAC5D;EAEA,IAAI,SAAS;GACX,MAAM,iEAA+B,KAAK,aAAa;GAEvD,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACvC,UAAU,2DAA2D,EACnE,WAAW,KACb,CAAC;GAGH,MAAM,kBAAkB,0DAA8B,YAAY;GAElE,IAAI,mBAAmB,gBAAgB,SAAS,GAC9C,UACE,CACE,0BACA,gBAAgB,KAAK,8CAAiB,KAAKA,4BAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAC7D,GACA,EACE,WAAW,KACb,CACF;GAGF,MAAM;IACJ,GAAG;IAGH,wDAA0B,iBAAiB,SAAS,SAAS;IAI7D,qHAC2B,YAAY,GACrC,SACA,SACF;GACF;EACF;EAEA,IAAI,QAAQ,aAAa;GASvB,eAAe;GACf,GAAG;EACL,CAAC,CAAC,CAAC,MAAM,QAAQ;EAKjB,IAAI,CAAC,WAAW,KAAK,cAAc,QAAQ,OAEzC,0CAAY,EAAE,eAAe,KAAK,cAAc,CAAC;CAErD;AACF"}
1
+ {"version":3,"file":"webpack-plugin.cjs","names":["getConfiguration","getAppLogger","prepareIntlayer","getConfigEnvVars","getDictionaries","getUnusedNodeTypesAsync","colorize","BLUE","formatNodeTypeToEnvVar","formatDictionarySelectorEnvVar","getHasDictionarySelector","watch"],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { BLUE } from '@intlayer/config/colors';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { watch } from '@intlayer/engine/watcher';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Compiler } from 'webpack';\n\n/**\n * Minimal structural view of a webpack `DefinePlugin` instance, limited to the\n * `definitions` record it exposes. Typed locally rather than imported because\n * `webpack.DefinePlugin` is reachable only through the `Compiler` instance at\n * runtime, and the host bundler may resolve its own webpack copy.\n */\ntype DefinePluginLike = {\n definitions?: Record<string, unknown>;\n};\n\n/**\n * Narrows an entry of `compiler.options.plugins` to a `DefinePlugin` instance.\n *\n * @param plugin - Any entry of the webpack `plugins` array (may be a function,\n * `undefined` or `false` when the host config uses conditional\n * plugin lists).\n */\nconst isDefinePlugin = (plugin: unknown): plugin is DefinePluginLike =>\n typeof plugin === 'object' &&\n plugin !== null &&\n plugin.constructor?.name === 'DefinePlugin';\n\n/**\n * Checks whether the host bundler already replaces the whole `process.env`\n * expression through its own `DefinePlugin`.\n *\n * Create React App defines `process.env` as an object literal holding its\n * `REACT_APP_*` variables. Declaring a second, differently-valued `process.env`\n * makes webpack emit `Conflicting values for 'process.env'`, which CRA\n * escalates to a build failure whenever `process.env.CI` is set (the default on\n * CI servers). When the host already provides that replacement, every\n * `process.env.*` read resolves against its object literal instead of a bare\n * `process`, so the catch-all define is redundant and can be skipped.\n *\n * @param compiler - The webpack compiler the Intlayer plugin is applied to.\n */\nconst getHasHostProcessEnvDefine = (compiler: Compiler): boolean =>\n (compiler.options.plugins ?? []).some(\n (plugin) =>\n isDefinePlugin(plugin) && 'process.env' in (plugin.definitions ?? {})\n );\n\n// Watch mode or on time build\nexport class IntlayerPlugin {\n private isWatching = false; // Flag to ensure we only start the watcher after the first build\n private configuration;\n\n constructor(configuration?: IntlayerConfig) {\n this.configuration = configuration ?? getConfiguration();\n }\n\n async apply(compiler: Compiler): Promise<void> {\n const { webpack } = compiler;\n\n const isBuild = compiler.options.mode !== 'development';\n\n const appLogger = getAppLogger(this.configuration);\n\n // Register the dictionary preparation tap *synchronously*, before any\n // `await` below. webpack does not await a plugin's async `apply`, so any\n // hook tapped after an `await` (e.g. after `watch()`) may register too late\n // — after `beforeCompile` has already fired — leaving the `.intlayer`\n // dictionaries entry unbuilt when module resolution starts and breaking the\n // build with `Can't resolve '@intlayer/dictionaries-entry'`. Tapping here\n // guarantees the entry is prepared before compilation begins.\n compiler.hooks.beforeCompile.tapPromise('IntlayerPlugin', async () => {\n if (!this.isWatching) {\n try {\n await prepareIntlayer(this.configuration);\n this.isWatching = true;\n } catch (error) {\n appLogger(`Error in IntlayerPlugin: ${error}`, {\n level: 'error',\n });\n }\n }\n });\n\n const wrapKey = (key: string) => `process.env.${key}`;\n const wrapValue = (value: string) => `\"${value}\"`;\n\n // Specific `process.env.<KEY>` defines. webpack's DefinePlugin replaces both\n // the dot- and bracket-notation reads of a defined key, and — crucially —\n // folds them at *parse* time, which lets it dead-code-eliminate the guarded\n // dynamic `import()` chunks (e.g. the HTML/markdown renderers) for unused\n // node types. The config flags are emitted in every mode so routing/editor\n // behaviour is correct in dev too; the dictionary scan (used to prune node\n // types) only runs for production builds.\n let env: Record<string, string> = {\n ...getConfigEnvVars(this.configuration, wrapKey, wrapValue),\n };\n\n if (isBuild) {\n const dictionaries = getDictionaries(this.configuration);\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out plugins:',\n unusedNodeTypes.map((key) => colorize(key, BLUE)).join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n env = {\n ...env,\n\n // Tree shaking based on unused node types\n ...formatNodeTypeToEnvVar(unusedNodeTypes, wrapKey, wrapValue),\n\n // Tree shaking the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n wrapKey,\n wrapValue\n ),\n };\n }\n\n new webpack.DefinePlugin({\n // Catch-all so that any `process.env.*` read NOT folded by the specific\n // keys below still resolves to `undefined` instead of dereferencing a\n // bare `process`, which is not defined in browser bundles (e.g. Angular)\n // and throws `process is not defined`. This covers in-use node types\n // (never emitted as \"false\"), the dictionary selector when present, and\n // every read in development where the dictionary scan is skipped. Specific\n // keys (below) and host bundler defines (e.g. `process.env.NODE_ENV`) take\n // precedence over this object, so chunk-level tree shaking is preserved.\n // Omitted when the host bundler already defines `process.env` itself, as\n // two conflicting values for the same key make webpack warn — and CRA\n // turns that warning into an error under `CI=true`.\n ...(getHasHostProcessEnvDefine(compiler)\n ? {}\n : { 'process.env': '({})' }),\n ...env,\n }).apply(compiler);\n\n // Only watch content declarations for the dev server. A production build is\n // a one-off compilation: starting a file watcher there serves no purpose and\n // keeps a live `fsevents`/chokidar stream open for the whole build.\n if (!isBuild && this.configuration.content.watch) {\n // Start watching (assuming watch is also async)\n await watch({ configuration: this.configuration });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,MAAM,kBAAkB,WACtB,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,aAAa,SAAS;;;;;;;;;;;;;;;AAgB/B,MAAM,8BAA8B,cACjC,SAAS,QAAQ,WAAW,CAAC,EAAC,CAAE,MAC9B,WACC,eAAe,MAAM,KAAK,kBAAkB,OAAO,eAAe,CAAC,EACvE;AAGF,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,aAAa;CACrB,AAAQ;CAER,YAAY,eAAgC;EAC1C,KAAK,gBAAgB,qBAAiBA,wCAAiB;CACzD;CAEA,MAAM,MAAM,UAAmC;EAC7C,MAAM,EAAE,YAAY;EAEpB,MAAM,UAAU,SAAS,QAAQ,SAAS;EAE1C,MAAM,gBAAYC,sCAAa,KAAK,aAAa;EASjD,SAAS,MAAM,cAAc,WAAW,kBAAkB,YAAY;GACpE,IAAI,CAAC,KAAK,YACR,IAAI;IACF,UAAMC,wCAAgB,KAAK,aAAa;IACxC,KAAK,aAAa;GACpB,SAAS,OAAO;IACd,UAAU,4BAA4B,SAAS,EAC7C,OAAO,QACT,CAAC;GACH;EAEJ,CAAC;EAED,MAAM,WAAW,QAAgB,eAAe;EAChD,MAAM,aAAa,UAAkB,IAAI,MAAM;EAS/C,IAAI,MAA8B,EAChC,OAAGC,2CAAiB,KAAK,eAAe,SAAS,SAAS,EAC5D;EAEA,IAAI,SAAS;GACX,MAAM,mBAAeC,8CAAgB,KAAK,aAAa;GAEvD,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACvC,UAAU,2DAA2D,EACnE,WAAW,KACb,CAAC;GAGH,MAAM,kBAAkB,UAAMC,gDAAwB,YAAY;GAElE,IAAI,mBAAmB,gBAAgB,SAAS,GAC9C,UACE,CACE,0BACA,gBAAgB,KAAK,YAAQC,kCAAS,KAAKC,4BAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAC7D,GACA,EACE,WAAW,KACb,CACF;GAGF,MAAM;IACJ,GAAG;IAGH,OAAGC,iDAAuB,iBAAiB,SAAS,SAAS;IAI7D,OAAGC,6DACDC,iDAAyB,YAAY,GACrC,SACA,SACF;GACF;EACF;EAEA,IAAI,QAAQ,aAAa;GAYvB,GAAI,2BAA2B,QAAQ,IACnC,CAAC,IACD,EAAE,eAAe,OAAO;GAC5B,GAAG;EACL,CAAC,CAAC,CAAC,MAAM,QAAQ;EAKjB,IAAI,CAAC,WAAW,KAAK,cAAc,QAAQ,OAEzC,UAAMC,gCAAM,EAAE,eAAe,KAAK,cAAc,CAAC;CAErD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.config.cjs","names":["getEntries","IntlayerPlugin"],"sources":["../../src/webpack.config.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n// @ts-ignore - Export exists\nimport type { Configuration as WebPackConfiguration } from 'webpack';\nimport type { Configuration as DevServerConfiguration } from 'webpack-dev-server';\nimport { getEntries } from './getEntries';\nimport { defineDirname } from './utils';\nimport { IntlayerPlugin } from './webpack-plugin';\n\n// For web interface\nexport const devServerConfig: DevServerConfiguration = {\n // Enable hot module replacement\n hot: true,\n // Open the browser\n open: false,\n liveReload: false,\n\n // Enable compression\n compress: true,\n\n // History API fallback\n historyApiFallback: false,\n\n // Host and port\n host: 'localhost',\n port: 8080,\n\n watchFiles: './src/', // derived from content.fileExtensions + content.contentDir\n\n devMiddleware: {\n // Enable write to disk to reuse the output\n writeToDisk: true,\n },\n\n // Content base\n static: {},\n};\n\nexport const getWebpackConfig = (\n configuration: IntlayerConfig = getConfiguration()\n): WebPackConfiguration => {\n const { fileExtensions } = configuration.content;\n\n /**\n * Set the __dirname global variable to make the config work in both ESM and CJS environments\n */\n defineDirname();\n\n const webpackConfig: WebPackConfiguration = {\n // Define the environment mode (development or production)\n mode: 'production', // or 'production'\n // Entry point of the application\n target: 'node', // Specifies the target environment\n\n entry: () => getEntries(configuration),\n output: {\n clean: true, // Clean the output directory before emit\n library: 'IntlLayerContent',\n libraryTarget: 'umd',\n filename: `[name].bundle.js`,\n },\n\n cache: false,\n\n devtool: 'source-map',\n\n // stats: {\n // preset: 'errors-only',\n // warnings: false,\n // },\n ignoreWarnings: [/./],\n resolve: {\n // Resolve TypeScript, JavaScript and JSON files\n extensions: [\n '.ts',\n '.js',\n '.json',\n '.wasm',\n '.ts',\n '.tsx',\n '.mjs',\n '.cjs',\n ],\n modules: [\n // To find the loader module\n join(globalThis.__dirname, '..', 'node_modules'), // In the project node_modules\n join(process.cwd(), 'node_modules'), // In the project node_modules\n join(process.cwd(), 'node_modules', 'intlayer-cli', 'node_modules'), // Or via another project by importing intlayer\n join(\n process.cwd(),\n 'node_modules',\n 'intlayer-cli',\n 'node_modules',\n '@intlayer/webpack',\n 'node_modules'\n ), // Or via another project by importing intlayer\n ],\n },\n\n resolveLoader: {\n // Configure how Webpack finds `loader` modules.\n modules: [\n // To find the loader module\n join(process.cwd(), 'node_modules'), // In the project node_modules\n join(\n process.cwd(),\n 'node_modules',\n '@intlayer/webpack',\n 'node_modules'\n ), // Or via another project by importing @intlayer/webpack\n join(\n process.cwd(),\n 'node_modules',\n 'intlayer-cli',\n 'node_modules',\n '@intlayer/webpack',\n 'node_modules'\n ), // Or via another project by importing intlayer\n ],\n },\n\n module: {\n rules: [\n {\n // Rule for .content.ts files\n test: new RegExp(`(${fileExtensions.join('|')})$`),\n use: [\n {\n // Transpile with esbuild-loader\n loader: 'esbuild-loader',\n options: {\n // JavaScript version to compile to\n target: 'es2015',\n },\n },\n // {\n // // Custom loader to process the transpiled code\n // loader: resolve('./intlayer-loader'),\n // },\n ],\n },\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n // Use esbuild to compile JavaScript & TypeScript\n {\n // Match `.js`, `.jsx`, `.ts` or `.tsx` files\n test: /\\.(jsx|js|ts|tsx|mjs|cjs)?$/,\n loader: 'esbuild-loader',\n options: {\n // JavaScript version to compile to\n target: 'es2015',\n },\n },\n\n // JSON files are supported natively by Webpack 5, no specific loader required\n ],\n },\n devServer: devServerConfig,\n\n plugins: [new IntlayerPlugin(configuration)],\n };\n\n return webpackConfig;\n};\n\nexport default getWebpackConfig;\n"],"mappings":";;;;;;;;AAWA,MAAa,kBAA0C;CAErD,KAAK;CAEL,MAAM;CACN,YAAY;CAGZ,UAAU;CAGV,oBAAoB;CAGpB,MAAM;CACN,MAAM;CAEN,YAAY;CAEZ,eAAe,EAEb,aAAa,KACf;CAGA,QAAQ,CAAC;AACX;AAEA,MAAa,oBACX,4DAAiD,MACxB;CACzB,MAAM,EAAE,mBAAmB,cAAc;;;;CAKzC,4BAAc;CAsHd,OAAO;EAlHL,MAAM;EAEN,QAAQ;EAER,aAAaA,8BAAW,aAAa;EACrC,QAAQ;GACN,OAAO;GACP,SAAS;GACT,eAAe;GACf,UAAU;EACZ;EAEA,OAAO;EAEP,SAAS;EAMT,gBAAgB,CAAC,GAAG;EACpB,SAAS;GAEP,YAAY;IACV;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA,SAAS;wBAEF,WAAW,WAAW,MAAM,cAAc;wBAC1C,QAAQ,IAAI,GAAG,cAAc;wBAC7B,QAAQ,IAAI,GAAG,gBAAgB,gBAAgB,cAAc;wBAEhE,QAAQ,IAAI,GACZ,gBACA,gBACA,gBACA,qBACA,cACF;GACF;EACF;EAEA,eAAe,EAEb,SAAS;uBAEF,QAAQ,IAAI,GAAG,cAAc;uBAEhC,QAAQ,IAAI,GACZ,gBACA,qBACA,cACF;uBAEE,QAAQ,IAAI,GACZ,gBACA,gBACA,gBACA,qBACA,cACF;EACF,EACF;EAEA,QAAQ,EACN,OAAO;GACL;IAEE,MAAM,IAAI,OAAO,IAAI,eAAe,KAAK,GAAG,EAAE,GAAG;IACjD,KAAK,CACH;KAEE,QAAQ;KACR,SAAS,EAEP,QAAQ,SACV;IACF,CAKF;GACF;GACA;IACE,MAAM;IACN,QAAQ;GACV;GAEA;IAEE,MAAM;IACN,QAAQ;IACR,SAAS,EAEP,QAAQ,SACV;GACF;EAGF,EACF;EACA,WAAW;EAEX,SAAS,CAAC,IAAIC,sCAAe,aAAa,CAAC;CAG1B;AACrB"}
1
+ {"version":3,"file":"webpack.config.cjs","names":["getConfiguration","getEntries","join","IntlayerPlugin"],"sources":["../../src/webpack.config.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n// @ts-ignore - Export exists\nimport type { Configuration as WebPackConfiguration } from 'webpack';\nimport type { Configuration as DevServerConfiguration } from 'webpack-dev-server';\nimport { getEntries } from './getEntries';\nimport { defineDirname } from './utils';\nimport { IntlayerPlugin } from './webpack-plugin';\n\n// For web interface\nexport const devServerConfig: DevServerConfiguration = {\n // Enable hot module replacement\n hot: true,\n // Open the browser\n open: false,\n liveReload: false,\n\n // Enable compression\n compress: true,\n\n // History API fallback\n historyApiFallback: false,\n\n // Host and port\n host: 'localhost',\n port: 8080,\n\n watchFiles: './src/', // derived from content.fileExtensions + content.contentDir\n\n devMiddleware: {\n // Enable write to disk to reuse the output\n writeToDisk: true,\n },\n\n // Content base\n static: {},\n};\n\nexport const getWebpackConfig = (\n configuration: IntlayerConfig = getConfiguration()\n): WebPackConfiguration => {\n const { fileExtensions } = configuration.content;\n\n /**\n * Set the __dirname global variable to make the config work in both ESM and CJS environments\n */\n defineDirname();\n\n const webpackConfig: WebPackConfiguration = {\n // Define the environment mode (development or production)\n mode: 'production', // or 'production'\n // Entry point of the application\n target: 'node', // Specifies the target environment\n\n entry: () => getEntries(configuration),\n output: {\n clean: true, // Clean the output directory before emit\n library: 'IntlLayerContent',\n libraryTarget: 'umd',\n filename: `[name].bundle.js`,\n },\n\n cache: false,\n\n devtool: 'source-map',\n\n // stats: {\n // preset: 'errors-only',\n // warnings: false,\n // },\n ignoreWarnings: [/./],\n resolve: {\n // Resolve TypeScript, JavaScript and JSON files\n extensions: [\n '.ts',\n '.js',\n '.json',\n '.wasm',\n '.ts',\n '.tsx',\n '.mjs',\n '.cjs',\n ],\n modules: [\n // To find the loader module\n join(globalThis.__dirname, '..', 'node_modules'), // In the project node_modules\n join(process.cwd(), 'node_modules'), // In the project node_modules\n join(process.cwd(), 'node_modules', 'intlayer-cli', 'node_modules'), // Or via another project by importing intlayer\n join(\n process.cwd(),\n 'node_modules',\n 'intlayer-cli',\n 'node_modules',\n '@intlayer/webpack',\n 'node_modules'\n ), // Or via another project by importing intlayer\n ],\n },\n\n resolveLoader: {\n // Configure how Webpack finds `loader` modules.\n modules: [\n // To find the loader module\n join(process.cwd(), 'node_modules'), // In the project node_modules\n join(\n process.cwd(),\n 'node_modules',\n '@intlayer/webpack',\n 'node_modules'\n ), // Or via another project by importing @intlayer/webpack\n join(\n process.cwd(),\n 'node_modules',\n 'intlayer-cli',\n 'node_modules',\n '@intlayer/webpack',\n 'node_modules'\n ), // Or via another project by importing intlayer\n ],\n },\n\n module: {\n rules: [\n {\n // Rule for .content.ts files\n test: new RegExp(`(${fileExtensions.join('|')})$`),\n use: [\n {\n // Transpile with esbuild-loader\n loader: 'esbuild-loader',\n options: {\n // JavaScript version to compile to\n target: 'es2015',\n },\n },\n // {\n // // Custom loader to process the transpiled code\n // loader: resolve('./intlayer-loader'),\n // },\n ],\n },\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n // Use esbuild to compile JavaScript & TypeScript\n {\n // Match `.js`, `.jsx`, `.ts` or `.tsx` files\n test: /\\.(jsx|js|ts|tsx|mjs|cjs)?$/,\n loader: 'esbuild-loader',\n options: {\n // JavaScript version to compile to\n target: 'es2015',\n },\n },\n\n // JSON files are supported natively by Webpack 5, no specific loader required\n ],\n },\n devServer: devServerConfig,\n\n plugins: [new IntlayerPlugin(configuration)],\n };\n\n return webpackConfig;\n};\n\nexport default getWebpackConfig;\n"],"mappings":";;;;;;;;AAWA,MAAa,kBAA0C;CAErD,KAAK;CAEL,MAAM;CACN,YAAY;CAGZ,UAAU;CAGV,oBAAoB;CAGpB,MAAM;CACN,MAAM;CAEN,YAAY;CAEZ,eAAe,EAEb,aAAa,KACf;CAGA,QAAQ,CAAC;AACX;AAEA,MAAa,oBACX,oBAAgCA,wCAAiB,MACxB;CACzB,MAAM,EAAE,mBAAmB,cAAc;;;;CAKzC,4BAAc;CAsHd,OAAO;EAlHL,MAAM;EAEN,QAAQ;EAER,aAAaC,8BAAW,aAAa;EACrC,QAAQ;GACN,OAAO;GACP,SAAS;GACT,eAAe;GACf,UAAU;EACZ;EAEA,OAAO;EAEP,SAAS;EAMT,gBAAgB,CAAC,GAAG;EACpB,SAAS;GAEP,YAAY;IACV;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA,SAAS;QAEPC,gBAAK,WAAW,WAAW,MAAM,cAAc;QAC/CA,gBAAK,QAAQ,IAAI,GAAG,cAAc;QAClCA,gBAAK,QAAQ,IAAI,GAAG,gBAAgB,gBAAgB,cAAc;QAClEA,gBACE,QAAQ,IAAI,GACZ,gBACA,gBACA,gBACA,qBACA,cACF;GACF;EACF;EAEA,eAAe,EAEb,SAAS;OAEPA,gBAAK,QAAQ,IAAI,GAAG,cAAc;OAClCA,gBACE,QAAQ,IAAI,GACZ,gBACA,qBACA,cACF;OACAA,gBACE,QAAQ,IAAI,GACZ,gBACA,gBACA,gBACA,qBACA,cACF;EACF,EACF;EAEA,QAAQ,EACN,OAAO;GACL;IAEE,MAAM,IAAI,OAAO,IAAI,eAAe,KAAK,GAAG,EAAE,GAAG;IACjD,KAAK,CACH;KAEE,QAAQ;KACR,SAAS,EAEP,QAAQ,SACV;IACF,CAKF;GACF;GACA;IACE,MAAM;IACN,QAAQ;GACV;GAEA;IAEE,MAAM;IACN,QAAQ;IACR,SAAS,EAEP,QAAQ,SACV;GACF;EAGF,EACF;EACA,WAAW;EAEX,SAAS,CAAC,IAAIC,sCAAe,aAAa,CAAC;CAG1B;AACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config/utils';\n\n/**\n * Set the __dirname global variable to make the config work in both ESM and CJS environments\n */\nexport const defineDirname = () => {\n const filename = isESModule\n ? fileURLToPath(import.meta.url)\n : require('node:url').pathToFileURL(__filename).toString();\n\n globalThis.__filename = globalThis.__filename ?? filename;\n globalThis.__dirname = globalThis.__dirname ?? path.dirname(__filename);\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,sBAAsB;CACjC,MAAM,WAAW,aACb,cAAc,OAAO,KAAK,GAAG,cACrB,UAAU,CAAC,CAAC,cAAc,UAAU,CAAC,CAAC,SAAS;CAE3D,WAAW,aAAa,WAAW,cAAc;CACjD,WAAW,YAAY,WAAW,aAAa,KAAK,QAAQ,UAAU;AACxE"}
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config/utils';\n\n/**\n * Set the __dirname global variable to make the config work in both ESM and CJS environments\n */\nexport const defineDirname = () => {\n const filename = isESModule\n ? fileURLToPath(import.meta.url)\n : require('node:url').pathToFileURL(__filename).toString();\n\n globalThis.__filename = globalThis.__filename ?? filename;\n globalThis.__dirname = globalThis.__dirname ?? path.dirname(__filename);\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,sBAAsB;CACjC,MAAM,WAAW,aACb,cAAc,YAAY,GAAG,cACrB,UAAU,CAAC,CAAC,cAAc,UAAU,CAAC,CAAC,SAAS;CAE3D,WAAW,aAAa,WAAW,cAAc;CACjD,WAAW,YAAY,WAAW,aAAa,KAAK,QAAQ,UAAU;AACxE"}
@@ -8,6 +8,29 @@ import { prepareIntlayer } from "@intlayer/engine/build";
8
8
  import { watch } from "@intlayer/engine/watcher";
9
9
 
10
10
  //#region src/webpack-plugin.ts
11
+ /**
12
+ * Narrows an entry of `compiler.options.plugins` to a `DefinePlugin` instance.
13
+ *
14
+ * @param plugin - Any entry of the webpack `plugins` array (may be a function,
15
+ * `undefined` or `false` when the host config uses conditional
16
+ * plugin lists).
17
+ */
18
+ const isDefinePlugin = (plugin) => typeof plugin === "object" && plugin !== null && plugin.constructor?.name === "DefinePlugin";
19
+ /**
20
+ * Checks whether the host bundler already replaces the whole `process.env`
21
+ * expression through its own `DefinePlugin`.
22
+ *
23
+ * Create React App defines `process.env` as an object literal holding its
24
+ * `REACT_APP_*` variables. Declaring a second, differently-valued `process.env`
25
+ * makes webpack emit `Conflicting values for 'process.env'`, which CRA
26
+ * escalates to a build failure whenever `process.env.CI` is set (the default on
27
+ * CI servers). When the host already provides that replacement, every
28
+ * `process.env.*` read resolves against its object literal instead of a bare
29
+ * `process`, so the catch-all define is redundant and can be skipped.
30
+ *
31
+ * @param compiler - The webpack compiler the Intlayer plugin is applied to.
32
+ */
33
+ const getHasHostProcessEnvDefine = (compiler) => (compiler.options.plugins ?? []).some((plugin) => isDefinePlugin(plugin) && "process.env" in (plugin.definitions ?? {}));
11
34
  var IntlayerPlugin = class {
12
35
  isWatching = false;
13
36
  configuration;
@@ -41,7 +64,7 @@ var IntlayerPlugin = class {
41
64
  };
42
65
  }
43
66
  new webpack.DefinePlugin({
44
- "process.env": "({})",
67
+ ...getHasHostProcessEnvDefine(compiler) ? {} : { "process.env": "({})" },
45
68
  ...env
46
69
  }).apply(compiler);
47
70
  if (!isBuild && this.configuration.content.watch) await watch({ configuration: this.configuration });
@@ -1 +1 @@
1
- {"version":3,"file":"webpack-plugin.mjs","names":[],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { BLUE } from '@intlayer/config/colors';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { watch } from '@intlayer/engine/watcher';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Compiler } from 'webpack';\n\n// Watch mode or on time build\nexport class IntlayerPlugin {\n private isWatching = false; // Flag to ensure we only start the watcher after the first build\n private configuration;\n\n constructor(configuration?: IntlayerConfig) {\n this.configuration = configuration ?? getConfiguration();\n }\n\n async apply(compiler: Compiler): Promise<void> {\n const { webpack } = compiler;\n\n const isBuild = compiler.options.mode !== 'development';\n\n const appLogger = getAppLogger(this.configuration);\n\n // Register the dictionary preparation tap *synchronously*, before any\n // `await` below. webpack does not await a plugin's async `apply`, so any\n // hook tapped after an `await` (e.g. after `watch()`) may register too late\n // — after `beforeCompile` has already fired — leaving the `.intlayer`\n // dictionaries entry unbuilt when module resolution starts and breaking the\n // build with `Can't resolve '@intlayer/dictionaries-entry'`. Tapping here\n // guarantees the entry is prepared before compilation begins.\n compiler.hooks.beforeCompile.tapPromise('IntlayerPlugin', async () => {\n if (!this.isWatching) {\n try {\n await prepareIntlayer(this.configuration);\n this.isWatching = true;\n } catch (error) {\n appLogger(`Error in IntlayerPlugin: ${error}`, {\n level: 'error',\n });\n }\n }\n });\n\n const wrapKey = (key: string) => `process.env.${key}`;\n const wrapValue = (value: string) => `\"${value}\"`;\n\n // Specific `process.env.<KEY>` defines. webpack's DefinePlugin replaces both\n // the dot- and bracket-notation reads of a defined key, and — crucially —\n // folds them at *parse* time, which lets it dead-code-eliminate the guarded\n // dynamic `import()` chunks (e.g. the HTML/markdown renderers) for unused\n // node types. The config flags are emitted in every mode so routing/editor\n // behaviour is correct in dev too; the dictionary scan (used to prune node\n // types) only runs for production builds.\n let env: Record<string, string> = {\n ...getConfigEnvVars(this.configuration, wrapKey, wrapValue),\n };\n\n if (isBuild) {\n const dictionaries = getDictionaries(this.configuration);\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out plugins:',\n unusedNodeTypes.map((key) => colorize(key, BLUE)).join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n env = {\n ...env,\n\n // Tree shaking based on unused node types\n ...formatNodeTypeToEnvVar(unusedNodeTypes, wrapKey, wrapValue),\n\n // Tree shaking the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n wrapKey,\n wrapValue\n ),\n };\n }\n\n new webpack.DefinePlugin({\n // Catch-all so that any `process.env.*` read NOT folded by the specific\n // keys below still resolves to `undefined` instead of dereferencing a\n // bare `process`, which is not defined in browser bundles (e.g. Angular)\n // and throws `process is not defined`. This covers in-use node types\n // (never emitted as \"false\"), the dictionary selector when present, and\n // every read in development where the dictionary scan is skipped. Specific\n // keys (below) and host bundler defines (e.g. `process.env.NODE_ENV`) take\n // precedence over this object, so chunk-level tree shaking is preserved.\n 'process.env': '({})',\n ...env,\n }).apply(compiler);\n\n // Only watch content declarations for the dev server. A production build is\n // a one-off compilation: starting a file watcher there serves no purpose and\n // keeps a live `fsevents`/chokidar stream open for the whole build.\n if (!isBuild && this.configuration.content.watch) {\n // Start watching (assuming watch is also async)\n await watch({ configuration: this.configuration });\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAmBA,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,aAAa;CACrB,AAAQ;CAER,YAAY,eAAgC;EAC1C,KAAK,gBAAgB,iBAAiB,iBAAiB;CACzD;CAEA,MAAM,MAAM,UAAmC;EAC7C,MAAM,EAAE,YAAY;EAEpB,MAAM,UAAU,SAAS,QAAQ,SAAS;EAE1C,MAAM,YAAY,aAAa,KAAK,aAAa;EASjD,SAAS,MAAM,cAAc,WAAW,kBAAkB,YAAY;GACpE,IAAI,CAAC,KAAK,YACR,IAAI;IACF,MAAM,gBAAgB,KAAK,aAAa;IACxC,KAAK,aAAa;GACpB,SAAS,OAAO;IACd,UAAU,4BAA4B,SAAS,EAC7C,OAAO,QACT,CAAC;GACH;EAEJ,CAAC;EAED,MAAM,WAAW,QAAgB,eAAe;EAChD,MAAM,aAAa,UAAkB,IAAI,MAAM;EAS/C,IAAI,MAA8B,EAChC,GAAG,iBAAiB,KAAK,eAAe,SAAS,SAAS,EAC5D;EAEA,IAAI,SAAS;GACX,MAAM,eAAe,gBAAgB,KAAK,aAAa;GAEvD,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACvC,UAAU,2DAA2D,EACnE,WAAW,KACb,CAAC;GAGH,MAAM,kBAAkB,MAAM,wBAAwB,YAAY;GAElE,IAAI,mBAAmB,gBAAgB,SAAS,GAC9C,UACE,CACE,0BACA,gBAAgB,KAAK,QAAQ,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAC7D,GACA,EACE,WAAW,KACb,CACF;GAGF,MAAM;IACJ,GAAG;IAGH,GAAG,uBAAuB,iBAAiB,SAAS,SAAS;IAI7D,GAAG,+BACD,yBAAyB,YAAY,GACrC,SACA,SACF;GACF;EACF;EAEA,IAAI,QAAQ,aAAa;GASvB,eAAe;GACf,GAAG;EACL,CAAC,CAAC,CAAC,MAAM,QAAQ;EAKjB,IAAI,CAAC,WAAW,KAAK,cAAc,QAAQ,OAEzC,MAAM,MAAM,EAAE,eAAe,KAAK,cAAc,CAAC;CAErD;AACF"}
1
+ {"version":3,"file":"webpack-plugin.mjs","names":[],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { BLUE } from '@intlayer/config/colors';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { watch } from '@intlayer/engine/watcher';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Compiler } from 'webpack';\n\n/**\n * Minimal structural view of a webpack `DefinePlugin` instance, limited to the\n * `definitions` record it exposes. Typed locally rather than imported because\n * `webpack.DefinePlugin` is reachable only through the `Compiler` instance at\n * runtime, and the host bundler may resolve its own webpack copy.\n */\ntype DefinePluginLike = {\n definitions?: Record<string, unknown>;\n};\n\n/**\n * Narrows an entry of `compiler.options.plugins` to a `DefinePlugin` instance.\n *\n * @param plugin - Any entry of the webpack `plugins` array (may be a function,\n * `undefined` or `false` when the host config uses conditional\n * plugin lists).\n */\nconst isDefinePlugin = (plugin: unknown): plugin is DefinePluginLike =>\n typeof plugin === 'object' &&\n plugin !== null &&\n plugin.constructor?.name === 'DefinePlugin';\n\n/**\n * Checks whether the host bundler already replaces the whole `process.env`\n * expression through its own `DefinePlugin`.\n *\n * Create React App defines `process.env` as an object literal holding its\n * `REACT_APP_*` variables. Declaring a second, differently-valued `process.env`\n * makes webpack emit `Conflicting values for 'process.env'`, which CRA\n * escalates to a build failure whenever `process.env.CI` is set (the default on\n * CI servers). When the host already provides that replacement, every\n * `process.env.*` read resolves against its object literal instead of a bare\n * `process`, so the catch-all define is redundant and can be skipped.\n *\n * @param compiler - The webpack compiler the Intlayer plugin is applied to.\n */\nconst getHasHostProcessEnvDefine = (compiler: Compiler): boolean =>\n (compiler.options.plugins ?? []).some(\n (plugin) =>\n isDefinePlugin(plugin) && 'process.env' in (plugin.definitions ?? {})\n );\n\n// Watch mode or on time build\nexport class IntlayerPlugin {\n private isWatching = false; // Flag to ensure we only start the watcher after the first build\n private configuration;\n\n constructor(configuration?: IntlayerConfig) {\n this.configuration = configuration ?? getConfiguration();\n }\n\n async apply(compiler: Compiler): Promise<void> {\n const { webpack } = compiler;\n\n const isBuild = compiler.options.mode !== 'development';\n\n const appLogger = getAppLogger(this.configuration);\n\n // Register the dictionary preparation tap *synchronously*, before any\n // `await` below. webpack does not await a plugin's async `apply`, so any\n // hook tapped after an `await` (e.g. after `watch()`) may register too late\n // — after `beforeCompile` has already fired — leaving the `.intlayer`\n // dictionaries entry unbuilt when module resolution starts and breaking the\n // build with `Can't resolve '@intlayer/dictionaries-entry'`. Tapping here\n // guarantees the entry is prepared before compilation begins.\n compiler.hooks.beforeCompile.tapPromise('IntlayerPlugin', async () => {\n if (!this.isWatching) {\n try {\n await prepareIntlayer(this.configuration);\n this.isWatching = true;\n } catch (error) {\n appLogger(`Error in IntlayerPlugin: ${error}`, {\n level: 'error',\n });\n }\n }\n });\n\n const wrapKey = (key: string) => `process.env.${key}`;\n const wrapValue = (value: string) => `\"${value}\"`;\n\n // Specific `process.env.<KEY>` defines. webpack's DefinePlugin replaces both\n // the dot- and bracket-notation reads of a defined key, and — crucially —\n // folds them at *parse* time, which lets it dead-code-eliminate the guarded\n // dynamic `import()` chunks (e.g. the HTML/markdown renderers) for unused\n // node types. The config flags are emitted in every mode so routing/editor\n // behaviour is correct in dev too; the dictionary scan (used to prune node\n // types) only runs for production builds.\n let env: Record<string, string> = {\n ...getConfigEnvVars(this.configuration, wrapKey, wrapValue),\n };\n\n if (isBuild) {\n const dictionaries = getDictionaries(this.configuration);\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger('No dictionaries found. Please check your configuration.', {\n isVerbose: true,\n });\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out plugins:',\n unusedNodeTypes.map((key) => colorize(key, BLUE)).join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n env = {\n ...env,\n\n // Tree shaking based on unused node types\n ...formatNodeTypeToEnvVar(unusedNodeTypes, wrapKey, wrapValue),\n\n // Tree shaking the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n wrapKey,\n wrapValue\n ),\n };\n }\n\n new webpack.DefinePlugin({\n // Catch-all so that any `process.env.*` read NOT folded by the specific\n // keys below still resolves to `undefined` instead of dereferencing a\n // bare `process`, which is not defined in browser bundles (e.g. Angular)\n // and throws `process is not defined`. This covers in-use node types\n // (never emitted as \"false\"), the dictionary selector when present, and\n // every read in development where the dictionary scan is skipped. Specific\n // keys (below) and host bundler defines (e.g. `process.env.NODE_ENV`) take\n // precedence over this object, so chunk-level tree shaking is preserved.\n // Omitted when the host bundler already defines `process.env` itself, as\n // two conflicting values for the same key make webpack warn — and CRA\n // turns that warning into an error under `CI=true`.\n ...(getHasHostProcessEnvDefine(compiler)\n ? {}\n : { 'process.env': '({})' }),\n ...env,\n }).apply(compiler);\n\n // Only watch content declarations for the dev server. A production build is\n // a one-off compilation: starting a file watcher there serves no purpose and\n // keeps a live `fsevents`/chokidar stream open for the whole build.\n if (!isBuild && this.configuration.content.watch) {\n // Start watching (assuming watch is also async)\n await watch({ configuration: this.configuration });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAM,kBAAkB,WACtB,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,aAAa,SAAS;;;;;;;;;;;;;;;AAgB/B,MAAM,8BAA8B,cACjC,SAAS,QAAQ,WAAW,CAAC,EAAC,CAAE,MAC9B,WACC,eAAe,MAAM,KAAK,kBAAkB,OAAO,eAAe,CAAC,EACvE;AAGF,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,aAAa;CACrB,AAAQ;CAER,YAAY,eAAgC;EAC1C,KAAK,gBAAgB,iBAAiB,iBAAiB;CACzD;CAEA,MAAM,MAAM,UAAmC;EAC7C,MAAM,EAAE,YAAY;EAEpB,MAAM,UAAU,SAAS,QAAQ,SAAS;EAE1C,MAAM,YAAY,aAAa,KAAK,aAAa;EASjD,SAAS,MAAM,cAAc,WAAW,kBAAkB,YAAY;GACpE,IAAI,CAAC,KAAK,YACR,IAAI;IACF,MAAM,gBAAgB,KAAK,aAAa;IACxC,KAAK,aAAa;GACpB,SAAS,OAAO;IACd,UAAU,4BAA4B,SAAS,EAC7C,OAAO,QACT,CAAC;GACH;EAEJ,CAAC;EAED,MAAM,WAAW,QAAgB,eAAe;EAChD,MAAM,aAAa,UAAkB,IAAI,MAAM;EAS/C,IAAI,MAA8B,EAChC,GAAG,iBAAiB,KAAK,eAAe,SAAS,SAAS,EAC5D;EAEA,IAAI,SAAS;GACX,MAAM,eAAe,gBAAgB,KAAK,aAAa;GAEvD,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACvC,UAAU,2DAA2D,EACnE,WAAW,KACb,CAAC;GAGH,MAAM,kBAAkB,MAAM,wBAAwB,YAAY;GAElE,IAAI,mBAAmB,gBAAgB,SAAS,GAC9C,UACE,CACE,0BACA,gBAAgB,KAAK,QAAQ,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAC7D,GACA,EACE,WAAW,KACb,CACF;GAGF,MAAM;IACJ,GAAG;IAGH,GAAG,uBAAuB,iBAAiB,SAAS,SAAS;IAI7D,GAAG,+BACD,yBAAyB,YAAY,GACrC,SACA,SACF;GACF;EACF;EAEA,IAAI,QAAQ,aAAa;GAYvB,GAAI,2BAA2B,QAAQ,IACnC,CAAC,IACD,EAAE,eAAe,OAAO;GAC5B,GAAG;EACL,CAAC,CAAC,CAAC,MAAM,QAAQ;EAKjB,IAAI,CAAC,WAAW,KAAK,cAAc,QAAQ,OAEzC,MAAM,MAAM,EAAE,eAAe,KAAK,cAAc,CAAC;CAErD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"webpack-plugin.d.ts","names":[],"sources":["../../src/webpack-plugin.ts"],"mappings":";;;cAmBa;UACH;UACA;EAER,YAAY,gBAAgB;EAItB,MAAM,UAAU,WAAW"}
1
+ {"version":3,"file":"webpack-plugin.d.ts","names":[],"sources":["../../src/webpack-plugin.ts"],"mappings":";;;cA6Da;UACH;UACA;EAER,YAAY,gBAAgB;EAItB,MAAM,UAAU,WAAW"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/webpack",
3
- "version": "9.3.0",
3
+ "version": "9.3.2",
4
4
  "private": false,
5
5
  "description": "Webpack plugin for seamless integration with Intlayer, enhancing JavaScript apps built with React, Next.js and more.",
6
6
  "keywords": [
@@ -77,10 +77,10 @@
77
77
  "watch": "webpack --config ./webpack.config.ts --watch"
78
78
  },
79
79
  "dependencies": {
80
- "@intlayer/config": "9.3.0",
81
- "@intlayer/dictionaries-entry": "9.3.0",
82
- "@intlayer/engine": "9.3.0",
83
- "@intlayer/types": "9.3.0",
80
+ "@intlayer/config": "9.3.2",
81
+ "@intlayer/dictionaries-entry": "9.3.2",
82
+ "@intlayer/engine": "9.3.2",
83
+ "@intlayer/types": "9.3.2",
84
84
  "fast-glob": "3.3.3"
85
85
  },
86
86
  "devDependencies": {