@intlayer/webpack 9.0.0-canary.3 → 9.0.0-canary.6
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.
|
@@ -20,7 +20,9 @@ var IntlayerPlugin = class {
|
|
|
20
20
|
const { webpack } = compiler;
|
|
21
21
|
const isBuild = compiler.options.mode !== "development";
|
|
22
22
|
const appLogger = (0, _intlayer_config_logger.getAppLogger)(this.configuration);
|
|
23
|
-
|
|
23
|
+
const wrapKey = (key) => `process.env.${key}`;
|
|
24
|
+
const wrapValue = (value) => `"${value}"`;
|
|
25
|
+
let env = { ...(0, _intlayer_config_envVars.getConfigEnvVars)(this.configuration, wrapKey, wrapValue) };
|
|
24
26
|
if (isBuild) {
|
|
25
27
|
const dictionaries = (0, _intlayer_dictionaries_entry.getDictionaries)(this.configuration);
|
|
26
28
|
if (Object.keys(dictionaries).length === 0) appLogger("No dictionaries found. Please check your configuration.", { isVerbose: true });
|
|
@@ -28,11 +30,14 @@ var IntlayerPlugin = class {
|
|
|
28
30
|
if (unusedNodeTypes && unusedNodeTypes.length > 0) appLogger(["Filtering out plugins:", unusedNodeTypes.map((key) => (0, _intlayer_config_logger.colorize)(key, _intlayer_config_colors.BLUE)).join(", ")], { isVerbose: true });
|
|
29
31
|
env = {
|
|
30
32
|
...env,
|
|
31
|
-
...(0, _intlayer_config_envVars.formatNodeTypeToEnvVar)(unusedNodeTypes),
|
|
32
|
-
...(0, _intlayer_config_envVars.
|
|
33
|
+
...(0, _intlayer_config_envVars.formatNodeTypeToEnvVar)(unusedNodeTypes, wrapKey, wrapValue),
|
|
34
|
+
...(0, _intlayer_config_envVars.formatDictionarySelectorEnvVar)((0, _intlayer_config_utils.getHasDictionarySelector)(dictionaries), wrapKey, wrapValue)
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
new webpack.DefinePlugin(
|
|
37
|
+
new webpack.DefinePlugin({
|
|
38
|
+
"process.env": "({})",
|
|
39
|
+
...env
|
|
40
|
+
}).apply(compiler);
|
|
36
41
|
if (this.configuration.content.watch) await (0, _intlayer_chokidar_watcher.watch)({ configuration: this.configuration });
|
|
37
42
|
compiler.hooks.beforeCompile.tapPromise("IntlayerPlugin", async () => {
|
|
38
43
|
if (!this.isWatching) try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack-plugin.cjs","names":["BLUE"],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport { BLUE } from '@intlayer/config/colors';\nimport {\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {
|
|
1
|
+
{"version":3,"file":"webpack-plugin.cjs","names":["BLUE"],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport { 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 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 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 / meta records)\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 if (this.configuration.content.watch) {\n // Start watching (assuming watch is also async)\n await watch({ configuration: this.configuration });\n }\n\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}\n"],"mappings":";;;;;;;;;;;;AAmBA,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,aAAa;CACrB,AAAQ;CAER,YAAY,eAAgC;AAC1C,OAAK,gBAAgB,8DAAmC;;CAG1D,MAAM,MAAM,UAAmC;EAC7C,MAAM,EAAE,YAAY;EAEpB,MAAM,UAAU,SAAS,QAAQ,SAAS;EAE1C,MAAM,sDAAyB,KAAK,cAAc;EAElD,MAAM,WAAW,QAAgB,eAAe;EAChD,MAAM,aAAa,UAAkB,IAAI,MAAM;EAS/C,IAAI,MAA8B,EAChC,kDAAoB,KAAK,eAAe,SAAS,UAAU,EAC5D;AAED,MAAI,SAAS;GACX,MAAM,iEAA+B,KAAK,cAAc;AAExD,OAAI,OAAO,KAAK,aAAa,CAAC,WAAW,EACvC,WAAU,2DAA2D,EACnE,WAAW,MACZ,CAAC;GAGJ,MAAM,kBAAkB,0DAA8B,aAAa;AAEnE,OAAI,mBAAmB,gBAAgB,SAAS,EAC9C,WACE,CACE,0BACA,gBAAgB,KAAK,8CAAiB,KAAKA,6BAAK,CAAC,CAAC,KAAK,KAAK,CAC7D,EACD,EACE,WAAW,MACZ,CACF;AAGH,SAAM;IACJ,GAAG;IAGH,wDAA0B,iBAAiB,SAAS,UAAU;IAI9D,qHAC2B,aAAa,EACtC,SACA,UACD;IACF;;AAGH,MAAI,QAAQ,aAAa;GASvB,eAAe;GACf,GAAG;GACJ,CAAC,CAAC,MAAM,SAAS;AAElB,MAAI,KAAK,cAAc,QAAQ,MAE7B,6CAAY,EAAE,eAAe,KAAK,eAAe,CAAC;AAGpD,WAAS,MAAM,cAAc,WAAW,kBAAkB,YAAY;AACpE,OAAI,CAAC,KAAK,WACR,KAAI;AACF,wDAAsB,KAAK,cAAc;AACzC,SAAK,aAAa;YACX,OAAO;AACd,cAAU,4BAA4B,SAAS,EAC7C,OAAO,SACR,CAAC;;IAGN"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getUnusedNodeTypesAsync } from "@intlayer/config/utils";
|
|
1
|
+
import { getHasDictionarySelector, getUnusedNodeTypesAsync } from "@intlayer/config/utils";
|
|
2
2
|
import { getConfiguration } from "@intlayer/config/node";
|
|
3
3
|
import { prepareIntlayer } from "@intlayer/chokidar/build";
|
|
4
4
|
import { watch } from "@intlayer/chokidar/watcher";
|
|
5
5
|
import { BLUE } from "@intlayer/config/colors";
|
|
6
|
-
import { formatNodeTypeToEnvVar, getConfigEnvVars } from "@intlayer/config/envVars";
|
|
6
|
+
import { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, getConfigEnvVars } from "@intlayer/config/envVars";
|
|
7
7
|
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
8
8
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
9
9
|
|
|
@@ -18,7 +18,9 @@ var IntlayerPlugin = class {
|
|
|
18
18
|
const { webpack } = compiler;
|
|
19
19
|
const isBuild = compiler.options.mode !== "development";
|
|
20
20
|
const appLogger = getAppLogger(this.configuration);
|
|
21
|
-
|
|
21
|
+
const wrapKey = (key) => `process.env.${key}`;
|
|
22
|
+
const wrapValue = (value) => `"${value}"`;
|
|
23
|
+
let env = { ...getConfigEnvVars(this.configuration, wrapKey, wrapValue) };
|
|
22
24
|
if (isBuild) {
|
|
23
25
|
const dictionaries = getDictionaries(this.configuration);
|
|
24
26
|
if (Object.keys(dictionaries).length === 0) appLogger("No dictionaries found. Please check your configuration.", { isVerbose: true });
|
|
@@ -26,11 +28,14 @@ var IntlayerPlugin = class {
|
|
|
26
28
|
if (unusedNodeTypes && unusedNodeTypes.length > 0) appLogger(["Filtering out plugins:", unusedNodeTypes.map((key) => colorize(key, BLUE)).join(", ")], { isVerbose: true });
|
|
27
29
|
env = {
|
|
28
30
|
...env,
|
|
29
|
-
...formatNodeTypeToEnvVar(unusedNodeTypes),
|
|
30
|
-
...
|
|
31
|
+
...formatNodeTypeToEnvVar(unusedNodeTypes, wrapKey, wrapValue),
|
|
32
|
+
...formatDictionarySelectorEnvVar(getHasDictionarySelector(dictionaries), wrapKey, wrapValue)
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
|
-
new webpack.DefinePlugin(
|
|
35
|
+
new webpack.DefinePlugin({
|
|
36
|
+
"process.env": "({})",
|
|
37
|
+
...env
|
|
38
|
+
}).apply(compiler);
|
|
34
39
|
if (this.configuration.content.watch) await watch({ configuration: this.configuration });
|
|
35
40
|
compiler.hooks.beforeCompile.tapPromise("IntlayerPlugin", async () => {
|
|
36
41
|
if (!this.isWatching) try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack-plugin.mjs","names":[],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport { BLUE } from '@intlayer/config/colors';\nimport {\n formatNodeTypeToEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {
|
|
1
|
+
{"version":3,"file":"webpack-plugin.mjs","names":[],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport { 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 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 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 / meta records)\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 if (this.configuration.content.watch) {\n // Start watching (assuming watch is also async)\n await watch({ configuration: this.configuration });\n }\n\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}\n"],"mappings":";;;;;;;;;;AAmBA,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,aAAa;CACrB,AAAQ;CAER,YAAY,eAAgC;AAC1C,OAAK,gBAAgB,iBAAiB,kBAAkB;;CAG1D,MAAM,MAAM,UAAmC;EAC7C,MAAM,EAAE,YAAY;EAEpB,MAAM,UAAU,SAAS,QAAQ,SAAS;EAE1C,MAAM,YAAY,aAAa,KAAK,cAAc;EAElD,MAAM,WAAW,QAAgB,eAAe;EAChD,MAAM,aAAa,UAAkB,IAAI,MAAM;EAS/C,IAAI,MAA8B,EAChC,GAAG,iBAAiB,KAAK,eAAe,SAAS,UAAU,EAC5D;AAED,MAAI,SAAS;GACX,MAAM,eAAe,gBAAgB,KAAK,cAAc;AAExD,OAAI,OAAO,KAAK,aAAa,CAAC,WAAW,EACvC,WAAU,2DAA2D,EACnE,WAAW,MACZ,CAAC;GAGJ,MAAM,kBAAkB,MAAM,wBAAwB,aAAa;AAEnE,OAAI,mBAAmB,gBAAgB,SAAS,EAC9C,WACE,CACE,0BACA,gBAAgB,KAAK,QAAQ,SAAS,KAAK,KAAK,CAAC,CAAC,KAAK,KAAK,CAC7D,EACD,EACE,WAAW,MACZ,CACF;AAGH,SAAM;IACJ,GAAG;IAGH,GAAG,uBAAuB,iBAAiB,SAAS,UAAU;IAI9D,GAAG,+BACD,yBAAyB,aAAa,EACtC,SACA,UACD;IACF;;AAGH,MAAI,QAAQ,aAAa;GASvB,eAAe;GACf,GAAG;GACJ,CAAC,CAAC,MAAM,SAAS;AAElB,MAAI,KAAK,cAAc,QAAQ,MAE7B,OAAM,MAAM,EAAE,eAAe,KAAK,eAAe,CAAC;AAGpD,WAAS,MAAM,cAAc,WAAW,kBAAkB,YAAY;AACpE,OAAI,CAAC,KAAK,WACR,KAAI;AACF,UAAM,gBAAgB,KAAK,cAAc;AACzC,SAAK,aAAa;YACX,OAAO;AACd,cAAU,4BAA4B,SAAS,EAC7C,OAAO,SACR,CAAC;;IAGN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack-plugin.d.ts","names":[],"sources":["../../src/webpack-plugin.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"webpack-plugin.d.ts","names":[],"sources":["../../src/webpack-plugin.ts"],"mappings":";;;;cAmBa,cAAA;EAAA,QACH,UAAA;EAAA,QACA,aAAA;cAEI,aAAA,GAAgB,cAAA;EAItB,KAAA,CAAM,QAAA,EAAU,QAAA,GAAW,OAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/webpack",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.6",
|
|
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,16 +77,16 @@
|
|
|
77
77
|
"watch": "webpack --config ./webpack.config.ts --watch"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@intlayer/chokidar": "9.0.0-canary.
|
|
81
|
-
"@intlayer/config": "9.0.0-canary.
|
|
82
|
-
"@intlayer/dictionaries-entry": "9.0.0-canary.
|
|
83
|
-
"@intlayer/types": "9.0.0-canary.
|
|
80
|
+
"@intlayer/chokidar": "9.0.0-canary.6",
|
|
81
|
+
"@intlayer/config": "9.0.0-canary.6",
|
|
82
|
+
"@intlayer/dictionaries-entry": "9.0.0-canary.6",
|
|
83
|
+
"@intlayer/types": "9.0.0-canary.6",
|
|
84
84
|
"fast-glob": "3.3.3",
|
|
85
85
|
"webpack": "5.107.2",
|
|
86
86
|
"webpack-dev-server": "5.2.4"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@types/node": "25.9.
|
|
89
|
+
"@types/node": "25.9.4",
|
|
90
90
|
"@utils/ts-config": "1.0.4",
|
|
91
91
|
"@utils/ts-config-types": "1.0.4",
|
|
92
92
|
"@utils/tsdown-config": "1.0.4",
|