react-scripts-intlayer 5.4.2 → 5.5.0
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/dist/cjs/cli/react-scripts-intlayer.cjs +4 -4
- package/dist/cjs/cli/react-scripts-intlayer.cjs.map +1 -1
- package/dist/cjs/intlayerCracoPlugin.cjs +9 -1
- package/dist/cjs/intlayerCracoPlugin.cjs.map +1 -1
- package/dist/esm/cli/react-scripts-intlayer.mjs +5 -5
- package/dist/esm/cli/react-scripts-intlayer.mjs.map +1 -1
- package/dist/esm/intlayerCracoPlugin.mjs +10 -2
- package/dist/esm/intlayerCracoPlugin.mjs.map +1 -1
- package/dist/types/intlayerCracoPlugin.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -48,13 +48,13 @@ switch (script) {
|
|
|
48
48
|
});
|
|
49
49
|
if (child.signal) {
|
|
50
50
|
if (child.signal === "SIGKILL") {
|
|
51
|
-
(0, import_config.
|
|
51
|
+
(0, import_config.logger)(`
|
|
52
52
|
The build failed because the process exited too early.
|
|
53
53
|
This probably means the system ran out of memory or someone called
|
|
54
54
|
\`kill -9\` on the process.
|
|
55
55
|
`);
|
|
56
56
|
} else if (child.signal === "SIGTERM") {
|
|
57
|
-
(0, import_config.
|
|
57
|
+
(0, import_config.logger)(`
|
|
58
58
|
The build failed because the process exited too early.
|
|
59
59
|
Someone might have called \`kill\` or \`killall\`, or the system could
|
|
60
60
|
be shutting down.
|
|
@@ -66,8 +66,8 @@ switch (script) {
|
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
default:
|
|
69
|
-
(0, import_config.
|
|
70
|
-
(0, import_config.
|
|
69
|
+
(0, import_config.logger)(`Unknown script "${script}".`);
|
|
70
|
+
(0, import_config.logger)("Perhaps you need to update craco?");
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
//# sourceMappingURL=react-scripts-intlayer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/react-scripts-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport { ESMxCJSRequire,
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/react-scripts-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport { ESMxCJSRequire, logger } from '@intlayer/config';\nimport spawn from 'cross-spawn';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (x) => x === 'build' || x === 'start' || x === 'test'\n);\nconst script = scriptIndex === -1 ? args[0] : args[scriptIndex];\n\nswitch (script) {\n case 'build':\n case 'start':\n case 'test': {\n const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];\n const scriptPath = ESMxCJSRequire.resolve(\n `@craco/craco/dist/scripts/${script}`\n );\n\n const scriptArgs = args.slice(scriptIndex + 1);\n const processArgs = nodeArgs\n .concat(scriptPath)\n .concat([\n ...scriptArgs,\n '--config',\n './node_modules/react-scripts-intlayer/dist/cjs/craco.config.cjs',\n ]);\n\n const child = spawn.sync('node', processArgs, {\n stdio: 'inherit',\n });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n logger(`\n The build failed because the process exited too early.\n This probably means the system ran out of memory or someone called\n \\`kill -9\\` on the process.\n `);\n } else if (child.signal === 'SIGTERM') {\n logger(`\n The build failed because the process exited too early.\n Someone might have called \\`kill\\` or \\`killall\\`, or the system could\n be shutting down.\n `);\n }\n\n process.exit(1);\n }\n\n process.exit(child.status ?? undefined);\n break;\n }\n default:\n logger(`Unknown script \"${script}\".`);\n logger('Perhaps you need to update craco?');\n break;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AASA,oBAAuC;AACvC,yBAAkB;AAElB,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,cAAc,KAAK;AAAA,EACvB,CAAC,MAAM,MAAM,WAAW,MAAM,WAAW,MAAM;AACjD;AACA,MAAM,SAAS,gBAAgB,KAAK,KAAK,CAAC,IAAI,KAAK,WAAW;AAE9D,QAAQ,QAAQ;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK,QAAQ;AACX,UAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,WAAW,IAAI,CAAC;AACjE,UAAM,aAAa,6BAAe;AAAA,MAChC,6BAA6B,MAAM;AAAA,IACrC;AAEA,UAAM,aAAa,KAAK,MAAM,cAAc,CAAC;AAC7C,UAAM,cAAc,SACjB,OAAO,UAAU,EACjB,OAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAEH,UAAM,QAAQ,mBAAAA,QAAM,KAAK,QAAQ,aAAa;AAAA,MAC5C,OAAO;AAAA,IACT,CAAC;AAED,QAAI,MAAM,QAAQ;AAChB,UAAI,MAAM,WAAW,WAAW;AAC9B,kCAAO;AAAA;AAAA;AAAA;AAAA,aAIF;AAAA,MACP,WAAW,MAAM,WAAW,WAAW;AACrC,kCAAO;AAAA;AAAA;AAAA;AAAA,aAIF;AAAA,MACP;AAEA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,MAAM,UAAU,MAAS;AACtC;AAAA,EACF;AAAA,EACA;AACE,8BAAO,mBAAmB,MAAM,IAAI;AACpC,8BAAO,mCAAmC;AAC1C;AACJ;","names":["spawn"]}
|
|
@@ -23,9 +23,9 @@ __export(intlayerCracoPlugin_exports, {
|
|
|
23
23
|
overrideWebpackConfig: () => overrideWebpackConfig
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(intlayerCracoPlugin_exports);
|
|
26
|
-
var import_path = require("path");
|
|
27
26
|
var import_config = require("@intlayer/config");
|
|
28
27
|
var import_webpack = require("@intlayer/webpack");
|
|
28
|
+
var import_path = require("path");
|
|
29
29
|
const intlayerConfig = (0, import_config.getConfiguration)();
|
|
30
30
|
const overrideWebpackConfig = ({
|
|
31
31
|
webpackConfig
|
|
@@ -51,6 +51,11 @@ const overrideCracoConfig = ({
|
|
|
51
51
|
const { mainDir, baseDir, configDir } = intlayerConfig.content;
|
|
52
52
|
const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
|
|
53
53
|
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
|
|
54
|
+
const unmergedDictionariesPath = (0, import_path.join)(mainDir, "unmerged_dictionaries.mjs");
|
|
55
|
+
const relativeUnmergedDictionariesPath = (0, import_path.relative)(
|
|
56
|
+
baseDir,
|
|
57
|
+
unmergedDictionariesPath
|
|
58
|
+
);
|
|
54
59
|
const configurationPath = (0, import_path.join)(configDir, "configuration.json");
|
|
55
60
|
const relativeConfigurationPath = (0, import_path.relative)(baseDir, configurationPath);
|
|
56
61
|
return {
|
|
@@ -84,6 +89,9 @@ const overrideCracoConfig = ({
|
|
|
84
89
|
alias: {
|
|
85
90
|
...cracoConfig.webpack?.alias,
|
|
86
91
|
"@intlayer/dictionaries-entry": (0, import_path.resolve)(relativeDictionariesPath),
|
|
92
|
+
"@intlayer/unmerged-dictionaries-entry": (0, import_path.resolve)(
|
|
93
|
+
relativeUnmergedDictionariesPath
|
|
94
|
+
),
|
|
87
95
|
"@intlayer/config/built": (0, import_path.resolve)(relativeConfigurationPath)
|
|
88
96
|
}
|
|
89
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerCracoPlugin.ts"],"sourcesContent":["// craco-intlayer-plugin.ts\n\n// @ts-nocheck\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerCracoPlugin.ts"],"sourcesContent":["// craco-intlayer-plugin.ts\n\n// @ts-nocheck\n\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { ESMxCJSRequire, getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin as IntlayerWebpackPlugin } from '@intlayer/webpack';\nimport { join, relative, resolve } from 'path';\nimport type { Configuration as WebpackConfig } from 'webpack';\n\n// Get Intlayer configuration\nconst intlayerConfig = getConfiguration();\n\n/**\n * Override the final CRA Webpack config.\n */\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n // 1) Remove `module`, `fs`, `path`, `vm` from externals. In CRA, you usually\n // want these to be bundled (or set to fallbacks).\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild', // keep only esbuild external\n };\n delete webpackConfig.externals.module;\n delete webpackConfig.externals.fs;\n delete webpackConfig.externals.path;\n delete webpackConfig.externals.vm;\n\n // 2) Properly push node-loader rule instead of overwriting.\n webpackConfig.module.rules.push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n return webpackConfig;\n};\n\n/**\n * Override the CRACO config itself to set up aliases, fallbacks, and plugins.\n */\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir, configDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(mainDir, 'unmerged_dictionaries.mjs');\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n // Ensure we actually add IntlayerWebpackPlugin\n add: [\n ...(cracoConfig.webpack?.plugins?.add ?? []),\n new IntlayerWebpackPlugin(),\n ],\n },\n configure: {\n ...(cracoConfig.webpack?.configure ?? {}),\n resolve: {\n ...(cracoConfig.webpack?.configure?.resolve ?? {}),\n // 3) Provide browser fallbacks so these modules won’t error out in the browser.\n fallback: {\n ...(cracoConfig.webpack?.configure?.resolve?.fallback ?? {}),\n process: ESMxCJSRequire.resolve('process/browser'),\n fs: false,\n module: false,\n path: false,\n vm: false,\n },\n },\n },\n // 4) Alias @intlayer/dictionaries-entry so it no longer tries to use the ESM that depends on `fs`, etc.\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the Intlayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin,\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n */\nexport const intlayerCracoPlugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,oBAAiD;AACjD,qBAAwD;AACxD,kBAAwC;AAIxC,MAAM,qBAAiB,gCAAiB;AAKjC,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAG1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA;AAAA,EACX;AACA,SAAO,cAAc,UAAU;AAC/B,SAAO,cAAc,UAAU;AAC/B,SAAO,cAAc,UAAU;AAC/B,SAAO,cAAc,UAAU;AAG/B,gBAAc,OAAO,MAAM,KAAK;AAAA,IAC9B,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAED,SAAO;AACT;AAKO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,SAAS,UAAU,IAAI,eAAe;AAEvD,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,QAAM,+BAA2B,kBAAK,SAAS,2BAA2B;AAC1E,QAAM,uCAAmC;AAAA,IACvC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,wBAAoB,kBAAK,WAAW,oBAAoB;AAC9D,QAAM,gCAA4B,sBAAS,SAAS,iBAAiB;AAErE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA;AAAA,QAExB,KAAK;AAAA,UACH,GAAI,YAAY,SAAS,SAAS,OAAO,CAAC;AAAA,UAC1C,IAAI,eAAAA,eAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,WAAW;AAAA,QACT,GAAI,YAAY,SAAS,aAAa,CAAC;AAAA,QACvC,SAAS;AAAA,UACP,GAAI,YAAY,SAAS,WAAW,WAAW,CAAC;AAAA;AAAA,UAEhD,UAAU;AAAA,YACR,GAAI,YAAY,SAAS,WAAW,SAAS,YAAY,CAAC;AAAA,YAC1D,SAAS,6BAAe,QAAQ,iBAAiB;AAAA,YACjD,IAAI;AAAA,YACJ,QAAQ;AAAA,YACR,MAAM;AAAA,YACN,IAAI;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA;AAAA,MAEA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,oCAAgC,qBAAQ,wBAAwB;AAAA,QAChE,6CAAyC;AAAA,UACvC;AAAA,QACF;AAAA,QACA,8BAA0B,qBAAQ,yBAAyB;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AACF;AAmBO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,EACA;AACF;","names":["IntlayerWebpackPlugin"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { ESMxCJSRequire,
|
|
2
|
+
import { ESMxCJSRequire, logger } from "@intlayer/config";
|
|
3
3
|
import spawn from "cross-spawn";
|
|
4
4
|
const args = process.argv.slice(2);
|
|
5
5
|
const scriptIndex = args.findIndex(
|
|
@@ -25,13 +25,13 @@ switch (script) {
|
|
|
25
25
|
});
|
|
26
26
|
if (child.signal) {
|
|
27
27
|
if (child.signal === "SIGKILL") {
|
|
28
|
-
|
|
28
|
+
logger(`
|
|
29
29
|
The build failed because the process exited too early.
|
|
30
30
|
This probably means the system ran out of memory or someone called
|
|
31
31
|
\`kill -9\` on the process.
|
|
32
32
|
`);
|
|
33
33
|
} else if (child.signal === "SIGTERM") {
|
|
34
|
-
|
|
34
|
+
logger(`
|
|
35
35
|
The build failed because the process exited too early.
|
|
36
36
|
Someone might have called \`kill\` or \`killall\`, or the system could
|
|
37
37
|
be shutting down.
|
|
@@ -43,8 +43,8 @@ switch (script) {
|
|
|
43
43
|
break;
|
|
44
44
|
}
|
|
45
45
|
default:
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
logger(`Unknown script "${script}".`);
|
|
47
|
+
logger("Perhaps you need to update craco?");
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
//# sourceMappingURL=react-scripts-intlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/react-scripts-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport { ESMxCJSRequire,
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/react-scripts-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport { ESMxCJSRequire, logger } from '@intlayer/config';\nimport spawn from 'cross-spawn';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (x) => x === 'build' || x === 'start' || x === 'test'\n);\nconst script = scriptIndex === -1 ? args[0] : args[scriptIndex];\n\nswitch (script) {\n case 'build':\n case 'start':\n case 'test': {\n const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];\n const scriptPath = ESMxCJSRequire.resolve(\n `@craco/craco/dist/scripts/${script}`\n );\n\n const scriptArgs = args.slice(scriptIndex + 1);\n const processArgs = nodeArgs\n .concat(scriptPath)\n .concat([\n ...scriptArgs,\n '--config',\n './node_modules/react-scripts-intlayer/dist/cjs/craco.config.cjs',\n ]);\n\n const child = spawn.sync('node', processArgs, {\n stdio: 'inherit',\n });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n logger(`\n The build failed because the process exited too early.\n This probably means the system ran out of memory or someone called\n \\`kill -9\\` on the process.\n `);\n } else if (child.signal === 'SIGTERM') {\n logger(`\n The build failed because the process exited too early.\n Someone might have called \\`kill\\` or \\`killall\\`, or the system could\n be shutting down.\n `);\n }\n\n process.exit(1);\n }\n\n process.exit(child.status ?? undefined);\n break;\n }\n default:\n logger(`Unknown script \"${script}\".`);\n logger('Perhaps you need to update craco?');\n break;\n}\n"],"mappings":";AASA,SAAS,gBAAgB,cAAc;AACvC,OAAO,WAAW;AAElB,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,cAAc,KAAK;AAAA,EACvB,CAAC,MAAM,MAAM,WAAW,MAAM,WAAW,MAAM;AACjD;AACA,MAAM,SAAS,gBAAgB,KAAK,KAAK,CAAC,IAAI,KAAK,WAAW;AAE9D,QAAQ,QAAQ;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK,QAAQ;AACX,UAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,WAAW,IAAI,CAAC;AACjE,UAAM,aAAa,eAAe;AAAA,MAChC,6BAA6B,MAAM;AAAA,IACrC;AAEA,UAAM,aAAa,KAAK,MAAM,cAAc,CAAC;AAC7C,UAAM,cAAc,SACjB,OAAO,UAAU,EACjB,OAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAEH,UAAM,QAAQ,MAAM,KAAK,QAAQ,aAAa;AAAA,MAC5C,OAAO;AAAA,IACT,CAAC;AAED,QAAI,MAAM,QAAQ;AAChB,UAAI,MAAM,WAAW,WAAW;AAC9B,eAAO;AAAA;AAAA;AAAA;AAAA,aAIF;AAAA,MACP,WAAW,MAAM,WAAW,WAAW;AACrC,eAAO;AAAA;AAAA;AAAA;AAAA,aAIF;AAAA,MACP;AAEA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,MAAM,UAAU,MAAS;AACtC;AAAA,EACF;AAAA,EACA;AACE,WAAO,mBAAmB,MAAM,IAAI;AACpC,WAAO,mCAAmC;AAC1C;AACJ;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./chunk-ZD7AOCMD.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { getConfiguration, ESMxCJSRequire } from "@intlayer/config";
|
|
2
|
+
import { ESMxCJSRequire, getConfiguration } from "@intlayer/config";
|
|
4
3
|
import { IntlayerPlugin as IntlayerWebpackPlugin } from "@intlayer/webpack";
|
|
4
|
+
import { join, relative, resolve } from "path";
|
|
5
5
|
const intlayerConfig = getConfiguration();
|
|
6
6
|
const overrideWebpackConfig = ({
|
|
7
7
|
webpackConfig
|
|
@@ -27,6 +27,11 @@ const overrideCracoConfig = ({
|
|
|
27
27
|
const { mainDir, baseDir, configDir } = intlayerConfig.content;
|
|
28
28
|
const dictionariesPath = join(mainDir, "dictionaries.mjs");
|
|
29
29
|
const relativeDictionariesPath = relative(baseDir, dictionariesPath);
|
|
30
|
+
const unmergedDictionariesPath = join(mainDir, "unmerged_dictionaries.mjs");
|
|
31
|
+
const relativeUnmergedDictionariesPath = relative(
|
|
32
|
+
baseDir,
|
|
33
|
+
unmergedDictionariesPath
|
|
34
|
+
);
|
|
30
35
|
const configurationPath = join(configDir, "configuration.json");
|
|
31
36
|
const relativeConfigurationPath = relative(baseDir, configurationPath);
|
|
32
37
|
return {
|
|
@@ -60,6 +65,9 @@ const overrideCracoConfig = ({
|
|
|
60
65
|
alias: {
|
|
61
66
|
...cracoConfig.webpack?.alias,
|
|
62
67
|
"@intlayer/dictionaries-entry": resolve(relativeDictionariesPath),
|
|
68
|
+
"@intlayer/unmerged-dictionaries-entry": resolve(
|
|
69
|
+
relativeUnmergedDictionariesPath
|
|
70
|
+
),
|
|
63
71
|
"@intlayer/config/built": resolve(relativeConfigurationPath)
|
|
64
72
|
}
|
|
65
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerCracoPlugin.ts"],"sourcesContent":["// craco-intlayer-plugin.ts\n\n// @ts-nocheck\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerCracoPlugin.ts"],"sourcesContent":["// craco-intlayer-plugin.ts\n\n// @ts-nocheck\n\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { ESMxCJSRequire, getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin as IntlayerWebpackPlugin } from '@intlayer/webpack';\nimport { join, relative, resolve } from 'path';\nimport type { Configuration as WebpackConfig } from 'webpack';\n\n// Get Intlayer configuration\nconst intlayerConfig = getConfiguration();\n\n/**\n * Override the final CRA Webpack config.\n */\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n // 1) Remove `module`, `fs`, `path`, `vm` from externals. In CRA, you usually\n // want these to be bundled (or set to fallbacks).\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild', // keep only esbuild external\n };\n delete webpackConfig.externals.module;\n delete webpackConfig.externals.fs;\n delete webpackConfig.externals.path;\n delete webpackConfig.externals.vm;\n\n // 2) Properly push node-loader rule instead of overwriting.\n webpackConfig.module.rules.push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n return webpackConfig;\n};\n\n/**\n * Override the CRACO config itself to set up aliases, fallbacks, and plugins.\n */\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir, configDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(mainDir, 'unmerged_dictionaries.mjs');\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n // Ensure we actually add IntlayerWebpackPlugin\n add: [\n ...(cracoConfig.webpack?.plugins?.add ?? []),\n new IntlayerWebpackPlugin(),\n ],\n },\n configure: {\n ...(cracoConfig.webpack?.configure ?? {}),\n resolve: {\n ...(cracoConfig.webpack?.configure?.resolve ?? {}),\n // 3) Provide browser fallbacks so these modules won’t error out in the browser.\n fallback: {\n ...(cracoConfig.webpack?.configure?.resolve?.fallback ?? {}),\n process: ESMxCJSRequire.resolve('process/browser'),\n fs: false,\n module: false,\n path: false,\n vm: false,\n },\n },\n },\n // 4) Alias @intlayer/dictionaries-entry so it no longer tries to use the ESM that depends on `fs`, etc.\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the Intlayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin,\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n */\nexport const intlayerCracoPlugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";AAUA,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,kBAAkB,6BAA6B;AACxD,SAAS,MAAM,UAAU,eAAe;AAIxC,MAAM,iBAAiB,iBAAiB;AAKjC,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAG1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA;AAAA,EACX;AACA,SAAO,cAAc,UAAU;AAC/B,SAAO,cAAc,UAAU;AAC/B,SAAO,cAAc,UAAU;AAC/B,SAAO,cAAc,UAAU;AAG/B,gBAAc,OAAO,MAAM,KAAK;AAAA,IAC9B,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAED,SAAO;AACT;AAKO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,SAAS,UAAU,IAAI,eAAe;AAEvD,QAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAEnE,QAAM,2BAA2B,KAAK,SAAS,2BAA2B;AAC1E,QAAM,mCAAmC;AAAA,IACvC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,oBAAoB,KAAK,WAAW,oBAAoB;AAC9D,QAAM,4BAA4B,SAAS,SAAS,iBAAiB;AAErE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA;AAAA,QAExB,KAAK;AAAA,UACH,GAAI,YAAY,SAAS,SAAS,OAAO,CAAC;AAAA,UAC1C,IAAI,sBAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,WAAW;AAAA,QACT,GAAI,YAAY,SAAS,aAAa,CAAC;AAAA,QACvC,SAAS;AAAA,UACP,GAAI,YAAY,SAAS,WAAW,WAAW,CAAC;AAAA;AAAA,UAEhD,UAAU;AAAA,YACR,GAAI,YAAY,SAAS,WAAW,SAAS,YAAY,CAAC;AAAA,YAC1D,SAAS,eAAe,QAAQ,iBAAiB;AAAA,YACjD,IAAI;AAAA,YACJ,QAAQ;AAAA,YACR,MAAM;AAAA,YACN,IAAI;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA;AAAA,MAEA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,gCAAgC,QAAQ,wBAAwB;AAAA,QAChE,yCAAyC;AAAA,UACvC;AAAA,QACF;AAAA,QACA,0BAA0B,QAAQ,yBAAyB;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AACF;AAmBO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,EACA;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerCracoPlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerCracoPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerCracoPlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerCracoPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAItB,OAAO,KAAK,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAK9D;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,oBAEnC,qBAAqB,KAAG,aAqB1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,kBAEjC,mBAAmB,KAAG,WAqDxB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAGjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-scripts-intlayer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Integrate Intlayer with Create React App using custom React scripts for internationalization i18n and advanced Webpack configurations",
|
|
6
6
|
"keywords": [
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"node-loader": "^2.1.0",
|
|
66
66
|
"process": "^0.11.10",
|
|
67
67
|
"webpack": "^5.98.0",
|
|
68
|
-
"@intlayer/config": "5.
|
|
69
|
-
"@intlayer/webpack": "5.
|
|
68
|
+
"@intlayer/config": "5.5.0",
|
|
69
|
+
"@intlayer/webpack": "5.5.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@craco/types": "^7.1.0",
|
|
@@ -81,16 +81,16 @@
|
|
|
81
81
|
"tsc-alias": "^1.8.11",
|
|
82
82
|
"tsup": "^8.4.0",
|
|
83
83
|
"typescript": "^5.8.2",
|
|
84
|
-
"@
|
|
84
|
+
"@intlayer/backend": "5.5.0",
|
|
85
85
|
"@utils/eslint-config": "1.0.4",
|
|
86
|
-
"@
|
|
87
|
-
"@utils/
|
|
88
|
-
"@utils/
|
|
86
|
+
"@utils/ts-config": "1.0.4",
|
|
87
|
+
"@utils/tsup-config": "1.0.4",
|
|
88
|
+
"@utils/ts-config-types": "1.0.4"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"webpack": ">=5.0.0",
|
|
92
|
-
"@intlayer/config": "5.
|
|
93
|
-
"@intlayer/webpack": "5.
|
|
92
|
+
"@intlayer/config": "5.5.0",
|
|
93
|
+
"@intlayer/webpack": "5.5.0"
|
|
94
94
|
},
|
|
95
95
|
"engines": {
|
|
96
96
|
"node": ">=14.18"
|