react-scripts-intlayer 9.0.0-canary.14 → 9.0.0-canary.16

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.
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ let _intlayer_config_node = require("@intlayer/config/node");
2
3
  let _intlayer_config_utils = require("@intlayer/config/utils");
3
4
  let node_child_process = require("node:child_process");
4
5
  let _intlayer_config_logger = require("@intlayer/config/logger");
@@ -13,39 +14,56 @@ let _intlayer_config_logger = require("@intlayer/config/logger");
13
14
  const args = process.argv.slice(2);
14
15
  const scriptIndex = args.findIndex((index) => index === "build" || index === "start" || index === "test");
15
16
  const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
16
- switch (script) {
17
- case "build":
18
- case "start":
19
- case "test": {
20
- const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
21
- const scriptPath = (0, _intlayer_config_utils.getProjectRequire)().resolve(`@craco/craco/dist/scripts/${script}`);
22
- const scriptArgs = args.slice(scriptIndex + 1);
23
- const child = (0, node_child_process.spawnSync)("node", nodeArgs.concat(scriptPath).concat([
24
- ...scriptArgs,
25
- "--config",
26
- "./node_modules/react-scripts-intlayer/dist/cjs/craco.config.cjs"
27
- ]), { stdio: "inherit" });
28
- if (child.signal) {
29
- if (child.signal === "SIGKILL") (0, _intlayer_config_logger.logger)(`
17
+ /**
18
+ * Build the Intlayer dictionaries (i.e. populate the `.intlayer` folder that
19
+ * backs the `@intlayer/dictionaries-entry` alias) before craco/webpack starts.
20
+ *
21
+ * Unlike the webpack `IntlayerPlugin` whose `beforeCompile` hook fires only
22
+ * after webpack has already begun resolving modules — this runs ahead of the
23
+ * compiler so the dictionaries entry exists the moment resolution starts.
24
+ * Mirrors the async `withIntlayer` flow used by the Next.js integration.
25
+ */
26
+ const prepareDictionaries = async (currentScript) => {
27
+ const isBuild = currentScript === "build";
28
+ const isDev = currentScript === "start";
29
+ const { prepareIntlayer } = await import("@intlayer/engine/build");
30
+ await prepareIntlayer((0, _intlayer_config_node.getConfiguration)(), {
31
+ clean: isBuild,
32
+ env: isBuild ? "prod" : "dev",
33
+ cacheTimeoutMs: isDev ? 1e3 * 60 * 60 : 1e3 * 30
34
+ });
35
+ };
36
+ const runScript = async () => {
37
+ if (script !== "build" && script !== "start" && script !== "test") {
38
+ (0, _intlayer_config_logger.logger)(`Unknown script "${script}".`);
39
+ (0, _intlayer_config_logger.logger)("Perhaps you need to update craco?");
40
+ return;
41
+ }
42
+ await prepareDictionaries(script);
43
+ const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
44
+ const scriptPath = (0, _intlayer_config_utils.getProjectRequire)().resolve(`@craco/craco/dist/scripts/${script}`);
45
+ const scriptArgs = args.slice(scriptIndex + 1);
46
+ const child = (0, node_child_process.spawnSync)("node", nodeArgs.concat(scriptPath).concat([
47
+ ...scriptArgs,
48
+ "--config",
49
+ "./node_modules/react-scripts-intlayer/dist/cjs/craco.config.cjs"
50
+ ]), { stdio: "inherit" });
51
+ if (child.signal) {
52
+ if (child.signal === "SIGKILL") (0, _intlayer_config_logger.logger)(`
30
53
  The build failed because the process exited too early.
31
54
  This probably means the system ran out of memory or someone called
32
55
  \`kill -9\` on the process.
33
56
  `);
34
- else if (child.signal === "SIGTERM") (0, _intlayer_config_logger.logger)(`
57
+ else if (child.signal === "SIGTERM") (0, _intlayer_config_logger.logger)(`
35
58
  The build failed because the process exited too early.
36
59
  Someone might have called \`kill\` or \`killall\`, or the system could
37
60
  be shutting down.
38
61
  `);
39
- process.exit(1);
40
- }
41
- process.exit(child.status ?? void 0);
42
- break;
62
+ process.exit(1);
43
63
  }
44
- default:
45
- (0, _intlayer_config_logger.logger)(`Unknown script "${script}".`);
46
- (0, _intlayer_config_logger.logger)("Perhaps you need to update craco?");
47
- break;
48
- }
64
+ process.exit(child.status ?? void 0);
65
+ };
66
+ runScript();
49
67
 
50
68
  //#endregion
51
69
  //# sourceMappingURL=react-scripts-intlayer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-scripts-intlayer.cjs","names":[],"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 { spawnSync } from 'node:child_process';\nimport { logger } from '@intlayer/config/logger';\nimport { getProjectRequire } from '@intlayer/config/utils';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (index) => index === 'build' || index === 'start' || index === '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 = getProjectRequire().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 = spawnSync('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":";;;;;;;;;;;;AAaA,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;AAClC,MAAM,cAAc,KAAK,WACtB,UAAU,UAAU,WAAW,UAAU,WAAW,UAAU,OAChE;AACD,MAAM,SAAS,gBAAgB,KAAK,KAAK,KAAK,KAAK;AAEnD,QAAQ,QAAR;CACE,KAAK;CACL,KAAK;CACL,KAAK,QAAQ;EACX,MAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,YAAY,GAAG,EAAE;EAClE,MAAM,4DAAgC,CAAC,QACrC,6BAA6B,SAC9B;EAED,MAAM,aAAa,KAAK,MAAM,cAAc,EAAE;EAS9C,MAAM,0CAAkB,QARJ,SACjB,OAAO,WAAW,CAClB,OAAO;GACN,GAAG;GACH;GACA;GACD,CAEwC,EAAE,EAC3C,OAAO,WACR,CAAC;AAEF,MAAI,MAAM,QAAQ;AAChB,OAAI,MAAM,WAAW,UACnB,qCAAO;;;;cAID;YACG,MAAM,WAAW,UAC1B,qCAAO;;;;cAID;AAGR,WAAQ,KAAK,EAAE;;AAGjB,UAAQ,KAAK,MAAM,UAAU,OAAU;AACvC;;CAEF;AACE,sCAAO,mBAAmB,OAAO,IAAI;AACrC,sCAAO,oCAAoC;AAC3C"}
1
+ {"version":3,"file":"react-scripts-intlayer.cjs","names":[],"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 { spawnSync } from 'node:child_process';\nimport { logger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getProjectRequire } from '@intlayer/config/utils';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (index) => index === 'build' || index === 'start' || index === 'test'\n);\nconst script = scriptIndex === -1 ? args[0] : args[scriptIndex];\n\n/**\n * Build the Intlayer dictionaries (i.e. populate the `.intlayer` folder that\n * backs the `@intlayer/dictionaries-entry` alias) before craco/webpack starts.\n *\n * Unlike the webpack `IntlayerPlugin` — whose `beforeCompile` hook fires only\n * after webpack has already begun resolving modules — this runs ahead of the\n * compiler so the dictionaries entry exists the moment resolution starts.\n * Mirrors the async `withIntlayer` flow used by the Next.js integration.\n */\nconst prepareDictionaries = async (\n currentScript: string | undefined\n): Promise<void> => {\n // `start` runs the dev server, `build` a production bundle, `test` the suite.\n const isBuild = currentScript === 'build';\n const isDev = currentScript === 'start';\n\n const { prepareIntlayer } = await import('@intlayer/engine/build');\n const intlayerConfig = getConfiguration();\n\n // `prepareIntlayer` uses `runOnce`, so a redundant call from the webpack\n // plugin later in the pipeline is a cheap no-op.\n await prepareIntlayer(intlayerConfig, {\n clean: isBuild,\n env: isBuild ? 'prod' : 'dev',\n cacheTimeoutMs: isDev\n ? 1000 * 60 * 60 // 1 hour for dev (default cache timeout)\n : 1000 * 30, // 30 seconds for build/test (ensure dictionaries are fresh)\n });\n};\n\nconst runScript = async (): Promise<void> => {\n if (script !== 'build' && script !== 'start' && script !== 'test') {\n logger(`Unknown script \"${script}\".`);\n logger('Perhaps you need to update craco?');\n return;\n }\n\n await prepareDictionaries(script);\n\n const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];\n const scriptPath = getProjectRequire().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 = spawnSync('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};\n\nrunScript();\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;AAClC,MAAM,cAAc,KAAK,WACtB,UAAU,UAAU,WAAW,UAAU,WAAW,UAAU,OAChE;AACD,MAAM,SAAS,gBAAgB,KAAK,KAAK,KAAK,KAAK;;;;;;;;;;AAWnD,MAAM,sBAAsB,OAC1B,kBACkB;CAElB,MAAM,UAAU,kBAAkB;CAClC,MAAM,QAAQ,kBAAkB;CAEhC,MAAM,EAAE,oBAAoB,MAAM,OAAO;AAKzC,OAAM,6DAA8B,EAAE;EACpC,OAAO;EACP,KAAK,UAAU,SAAS;EACxB,gBAAgB,QACZ,MAAO,KAAK,KACZ,MAAO;EACZ,CAAC;;AAGJ,MAAM,YAAY,YAA2B;AAC3C,KAAI,WAAW,WAAW,WAAW,WAAW,WAAW,QAAQ;AACjE,sCAAO,mBAAmB,OAAO,IAAI;AACrC,sCAAO,oCAAoC;AAC3C;;AAGF,OAAM,oBAAoB,OAAO;CAEjC,MAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,YAAY,GAAG,EAAE;CAClE,MAAM,4DAAgC,CAAC,QACrC,6BAA6B,SAC9B;CAED,MAAM,aAAa,KAAK,MAAM,cAAc,EAAE;CAS9C,MAAM,0CAAkB,QARJ,SACjB,OAAO,WAAW,CAClB,OAAO;EACN,GAAG;EACH;EACA;EACD,CAEwC,EAAE,EAC3C,OAAO,WACR,CAAC;AAEF,KAAI,MAAM,QAAQ;AAChB,MAAI,MAAM,WAAW,UACnB,qCAAO;;;;cAIC;WACC,MAAM,WAAW,UAC1B,qCAAO;;;;cAIC;AAGV,UAAQ,KAAK,EAAE;;AAGjB,SAAQ,KAAK,MAAM,UAAU,OAAU;;AAGzC,WAAW"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-scripts-intlayer",
3
- "version": "9.0.0-canary.14",
3
+ "version": "9.0.0-canary.16",
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": [
@@ -79,9 +79,10 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@craco/craco": "7.1.0",
82
- "@intlayer/config": "9.0.0-canary.14",
83
- "@intlayer/types": "9.0.0-canary.14",
84
- "@intlayer/webpack": "9.0.0-canary.14",
82
+ "@intlayer/config": "9.0.0-canary.16",
83
+ "@intlayer/engine": "9.0.0-canary.16",
84
+ "@intlayer/types": "9.0.0-canary.16",
85
+ "@intlayer/webpack": "9.0.0-canary.16",
85
86
  "defu": "6.1.7",
86
87
  "node-loader": "2.1.0",
87
88
  "process": "0.11.10",
@@ -98,7 +99,7 @@
98
99
  "rimraf": "6.1.3",
99
100
  "tsdown": "0.21.10",
100
101
  "typescript": "6.0.3",
101
- "vitest": "4.1.9"
102
+ "vitest": "4.1.10"
102
103
  },
103
104
  "peerDependencies": {
104
105
  "webpack": ">=5.0.0"