@intlayer/babel 9.0.0-canary.19 → 9.0.0-canary.20

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.
@@ -3,12 +3,12 @@ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_extractContent_utils_detectPackageName = require('./extractContent/utils/detectPackageName.cjs');
4
4
  const require_extractContent_extractContent = require('./extractContent/extractContent.cjs');
5
5
  const require_normalizedFilesList = require('./normalizedFilesList.cjs');
6
+ let _babel_parser = require("@babel/parser");
6
7
  let node_path = require("node:path");
7
8
  let _intlayer_config_colors = require("@intlayer/config/colors");
8
9
  _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
9
10
  let _intlayer_config_logger = require("@intlayer/config/logger");
10
11
  let _intlayer_config_utils = require("@intlayer/config/utils");
11
- let _babel_parser = require("@babel/parser");
12
12
 
13
13
  //#region src/babel-plugin-intlayer-extract.ts
14
14
  /**
@@ -0,0 +1,62 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _babel_parser = require("@babel/parser");
3
+
4
+ //#region src/babelParser.ts
5
+ /**
6
+ * Recast-compatible parsers backed by the `@babel/parser` version owned by
7
+ * `@intlayer/babel`.
8
+ *
9
+ * All Babel operations are centralized in this package so that consumers such
10
+ * as `@intlayer/engine` never need to depend on (or resolve) `@babel/parser`
11
+ * themselves. `@intlayer/engine` loads these parsers lazily, which keeps
12
+ * `@babel/parser` off the hot path until an AST transform is actually run.
13
+ *
14
+ * Recast's own `recast/parsers/typescript` / `recast/parsers/babel-ts` modules
15
+ * resolve `@babel/parser` from the hoisted dependency tree, which can pick up
16
+ * an incompatible major. Exposing the parser here resolves it against this
17
+ * package's own pinned dependency, keeping the `intlayer init` AST transforms
18
+ * working regardless of hoisting.
19
+ *
20
+ * The plugin list mirrors `recast/parsers/_babel_options.js`, adapted to the
21
+ * Babel 8 parser. Only the still-optional plugins are listed here: the many
22
+ * proposals that shipped as language features (e.g. class fields, private
23
+ * methods, static blocks, optional chaining, nullish coalescing, numeric
24
+ * separators, object rest/spread, dynamic import, top-level await, import
25
+ * attributes) are enabled by default in Babel 8 and no longer accepted as
26
+ * explicit plugins. Compared to the Babel 7 list, `decimal` and `recordAndTuple`
27
+ * were removed with their proposals, `importAssertions` became the default
28
+ * import-attributes syntax, and `pipelineOperator` uses the `fsharp` proposal
29
+ * (the `minimal` proposal was removed, and `hack` conflicts with `v8intrinsic`).
30
+ *
31
+ * The goal is still to tolerate as much syntax as possible, since these
32
+ * transforms run on arbitrary user code.
33
+ */
34
+ const buildBabelOptions = (extraPlugins) => ({
35
+ sourceType: "module",
36
+ strictMode: false,
37
+ allowImportExportEverywhere: true,
38
+ allowReturnOutsideFunction: true,
39
+ startLine: 1,
40
+ tokens: true,
41
+ plugins: [
42
+ "decorators-legacy",
43
+ "doExpressions",
44
+ "exportDefaultFrom",
45
+ "functionBind",
46
+ "functionSent",
47
+ "importMeta",
48
+ ["pipelineOperator", { proposal: "fsharp" }],
49
+ "throwExpressions",
50
+ "v8intrinsic",
51
+ ...extraPlugins
52
+ ]
53
+ });
54
+ /** Drop-in replacement for `recast/parsers/typescript` (TS without JSX). */
55
+ const typescriptParser = { parse: (source) => (0, _babel_parser.parse)(source, buildBabelOptions(["typescript"])) };
56
+ /** Drop-in replacement for `recast/parsers/babel-ts` (TS *and* JSX). */
57
+ const babelTsParser = { parse: (source) => (0, _babel_parser.parse)(source, buildBabelOptions(["jsx", "typescript"])) };
58
+
59
+ //#endregion
60
+ exports.babelTsParser = babelTsParser;
61
+ exports.typescriptParser = typescriptParser;
62
+ //# sourceMappingURL=babelParser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babelParser.cjs","names":[],"sources":["../../src/babelParser.ts"],"sourcesContent":["import { parse as babelParse, type ParserOptions } from '@babel/parser';\n\n/**\n * Recast-compatible parsers backed by the `@babel/parser` version owned by\n * `@intlayer/babel`.\n *\n * All Babel operations are centralized in this package so that consumers such\n * as `@intlayer/engine` never need to depend on (or resolve) `@babel/parser`\n * themselves. `@intlayer/engine` loads these parsers lazily, which keeps\n * `@babel/parser` off the hot path until an AST transform is actually run.\n *\n * Recast's own `recast/parsers/typescript` / `recast/parsers/babel-ts` modules\n * resolve `@babel/parser` from the hoisted dependency tree, which can pick up\n * an incompatible major. Exposing the parser here resolves it against this\n * package's own pinned dependency, keeping the `intlayer init` AST transforms\n * working regardless of hoisting.\n *\n * The plugin list mirrors `recast/parsers/_babel_options.js`, adapted to the\n * Babel 8 parser. Only the still-optional plugins are listed here: the many\n * proposals that shipped as language features (e.g. class fields, private\n * methods, static blocks, optional chaining, nullish coalescing, numeric\n * separators, object rest/spread, dynamic import, top-level await, import\n * attributes) are enabled by default in Babel 8 and no longer accepted as\n * explicit plugins. Compared to the Babel 7 list, `decimal` and `recordAndTuple`\n * were removed with their proposals, `importAssertions` became the default\n * import-attributes syntax, and `pipelineOperator` uses the `fsharp` proposal\n * (the `minimal` proposal was removed, and `hack` conflicts with `v8intrinsic`).\n *\n * The goal is still to tolerate as much syntax as possible, since these\n * transforms run on arbitrary user code.\n */\nconst buildBabelOptions = (\n extraPlugins: NonNullable<ParserOptions['plugins']>\n): ParserOptions => ({\n sourceType: 'module',\n strictMode: false,\n allowImportExportEverywhere: true,\n allowReturnOutsideFunction: true,\n startLine: 1,\n tokens: true,\n plugins: [\n 'decorators-legacy',\n 'doExpressions',\n 'exportDefaultFrom',\n 'functionBind',\n 'functionSent',\n 'importMeta',\n ['pipelineOperator', { proposal: 'fsharp' }],\n 'throwExpressions',\n 'v8intrinsic',\n ...extraPlugins,\n ],\n});\n\n/** A parser object accepted by `recast.parse`'s `parser` option. */\nexport type RecastParser = {\n parse: (source: string) => unknown;\n};\n\n/** Drop-in replacement for `recast/parsers/typescript` (TS without JSX). */\nexport const typescriptParser: RecastParser = {\n parse: (source: string) =>\n babelParse(source, buildBabelOptions(['typescript'])),\n};\n\n/** Drop-in replacement for `recast/parsers/babel-ts` (TS *and* JSX). */\nexport const babelTsParser: RecastParser = {\n parse: (source: string) =>\n babelParse(source, buildBabelOptions(['jsx', 'typescript'])),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,qBACJ,kBACmB;CACnB,YAAY;CACZ,YAAY;CACZ,6BAA6B;CAC7B,4BAA4B;CAC5B,WAAW;CACX,QAAQ;CACR,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA,CAAC,oBAAoB,EAAE,UAAU,SAAS,CAAC;EAC3C;EACA;EACA,GAAG;CACL;AACF;;AAQA,MAAa,mBAAiC,EAC5C,QAAQ,oCACK,QAAQ,kBAAkB,CAAC,YAAY,CAAC,CAAC,EACxD;;AAGA,MAAa,gBAA8B,EACzC,QAAQ,oCACK,QAAQ,kBAAkB,CAAC,OAAO,YAAY,CAAC,CAAC,EAC/D"}
@@ -2,9 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_extractContent_utils_constants = require('./utils/constants.cjs');
4
4
  const require_extractContent_babelProcessor = require('./babelProcessor.cjs');
5
+ let _babel_parser = require("@babel/parser");
5
6
  let node_fs = require("node:fs");
6
7
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
7
- let _babel_parser = require("@babel/parser");
8
8
  let node_child_process = require("node:child_process");
9
9
  let _babel_traverse = require("@babel/traverse");
10
10
  _babel_traverse = require_runtime.__toESM(_babel_traverse);
@@ -1,11 +1,11 @@
1
1
  import { detectPackageName } from "./extractContent/utils/detectPackageName.mjs";
2
2
  import { extractContentSync } from "./extractContent/extractContent.mjs";
3
3
  import { getNormalizedFilesListSet } from "./normalizedFilesList.mjs";
4
+ import { parse } from "@babel/parser";
4
5
  import { relative } from "node:path";
5
6
  import * as ANSIColors from "@intlayer/config/colors";
6
7
  import { colorize, colorizePath, getAppLogger } from "@intlayer/config/logger";
7
8
  import { normalizePath } from "@intlayer/config/utils";
8
- import { parse } from "@babel/parser";
9
9
 
10
10
  //#region src/babel-plugin-intlayer-extract.ts
11
11
  /**
@@ -0,0 +1,60 @@
1
+ import { parse } from "@babel/parser";
2
+
3
+ //#region src/babelParser.ts
4
+ /**
5
+ * Recast-compatible parsers backed by the `@babel/parser` version owned by
6
+ * `@intlayer/babel`.
7
+ *
8
+ * All Babel operations are centralized in this package so that consumers such
9
+ * as `@intlayer/engine` never need to depend on (or resolve) `@babel/parser`
10
+ * themselves. `@intlayer/engine` loads these parsers lazily, which keeps
11
+ * `@babel/parser` off the hot path until an AST transform is actually run.
12
+ *
13
+ * Recast's own `recast/parsers/typescript` / `recast/parsers/babel-ts` modules
14
+ * resolve `@babel/parser` from the hoisted dependency tree, which can pick up
15
+ * an incompatible major. Exposing the parser here resolves it against this
16
+ * package's own pinned dependency, keeping the `intlayer init` AST transforms
17
+ * working regardless of hoisting.
18
+ *
19
+ * The plugin list mirrors `recast/parsers/_babel_options.js`, adapted to the
20
+ * Babel 8 parser. Only the still-optional plugins are listed here: the many
21
+ * proposals that shipped as language features (e.g. class fields, private
22
+ * methods, static blocks, optional chaining, nullish coalescing, numeric
23
+ * separators, object rest/spread, dynamic import, top-level await, import
24
+ * attributes) are enabled by default in Babel 8 and no longer accepted as
25
+ * explicit plugins. Compared to the Babel 7 list, `decimal` and `recordAndTuple`
26
+ * were removed with their proposals, `importAssertions` became the default
27
+ * import-attributes syntax, and `pipelineOperator` uses the `fsharp` proposal
28
+ * (the `minimal` proposal was removed, and `hack` conflicts with `v8intrinsic`).
29
+ *
30
+ * The goal is still to tolerate as much syntax as possible, since these
31
+ * transforms run on arbitrary user code.
32
+ */
33
+ const buildBabelOptions = (extraPlugins) => ({
34
+ sourceType: "module",
35
+ strictMode: false,
36
+ allowImportExportEverywhere: true,
37
+ allowReturnOutsideFunction: true,
38
+ startLine: 1,
39
+ tokens: true,
40
+ plugins: [
41
+ "decorators-legacy",
42
+ "doExpressions",
43
+ "exportDefaultFrom",
44
+ "functionBind",
45
+ "functionSent",
46
+ "importMeta",
47
+ ["pipelineOperator", { proposal: "fsharp" }],
48
+ "throwExpressions",
49
+ "v8intrinsic",
50
+ ...extraPlugins
51
+ ]
52
+ });
53
+ /** Drop-in replacement for `recast/parsers/typescript` (TS without JSX). */
54
+ const typescriptParser = { parse: (source) => parse(source, buildBabelOptions(["typescript"])) };
55
+ /** Drop-in replacement for `recast/parsers/babel-ts` (TS *and* JSX). */
56
+ const babelTsParser = { parse: (source) => parse(source, buildBabelOptions(["jsx", "typescript"])) };
57
+
58
+ //#endregion
59
+ export { babelTsParser, typescriptParser };
60
+ //# sourceMappingURL=babelParser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babelParser.mjs","names":["babelParse"],"sources":["../../src/babelParser.ts"],"sourcesContent":["import { parse as babelParse, type ParserOptions } from '@babel/parser';\n\n/**\n * Recast-compatible parsers backed by the `@babel/parser` version owned by\n * `@intlayer/babel`.\n *\n * All Babel operations are centralized in this package so that consumers such\n * as `@intlayer/engine` never need to depend on (or resolve) `@babel/parser`\n * themselves. `@intlayer/engine` loads these parsers lazily, which keeps\n * `@babel/parser` off the hot path until an AST transform is actually run.\n *\n * Recast's own `recast/parsers/typescript` / `recast/parsers/babel-ts` modules\n * resolve `@babel/parser` from the hoisted dependency tree, which can pick up\n * an incompatible major. Exposing the parser here resolves it against this\n * package's own pinned dependency, keeping the `intlayer init` AST transforms\n * working regardless of hoisting.\n *\n * The plugin list mirrors `recast/parsers/_babel_options.js`, adapted to the\n * Babel 8 parser. Only the still-optional plugins are listed here: the many\n * proposals that shipped as language features (e.g. class fields, private\n * methods, static blocks, optional chaining, nullish coalescing, numeric\n * separators, object rest/spread, dynamic import, top-level await, import\n * attributes) are enabled by default in Babel 8 and no longer accepted as\n * explicit plugins. Compared to the Babel 7 list, `decimal` and `recordAndTuple`\n * were removed with their proposals, `importAssertions` became the default\n * import-attributes syntax, and `pipelineOperator` uses the `fsharp` proposal\n * (the `minimal` proposal was removed, and `hack` conflicts with `v8intrinsic`).\n *\n * The goal is still to tolerate as much syntax as possible, since these\n * transforms run on arbitrary user code.\n */\nconst buildBabelOptions = (\n extraPlugins: NonNullable<ParserOptions['plugins']>\n): ParserOptions => ({\n sourceType: 'module',\n strictMode: false,\n allowImportExportEverywhere: true,\n allowReturnOutsideFunction: true,\n startLine: 1,\n tokens: true,\n plugins: [\n 'decorators-legacy',\n 'doExpressions',\n 'exportDefaultFrom',\n 'functionBind',\n 'functionSent',\n 'importMeta',\n ['pipelineOperator', { proposal: 'fsharp' }],\n 'throwExpressions',\n 'v8intrinsic',\n ...extraPlugins,\n ],\n});\n\n/** A parser object accepted by `recast.parse`'s `parser` option. */\nexport type RecastParser = {\n parse: (source: string) => unknown;\n};\n\n/** Drop-in replacement for `recast/parsers/typescript` (TS without JSX). */\nexport const typescriptParser: RecastParser = {\n parse: (source: string) =>\n babelParse(source, buildBabelOptions(['typescript'])),\n};\n\n/** Drop-in replacement for `recast/parsers/babel-ts` (TS *and* JSX). */\nexport const babelTsParser: RecastParser = {\n parse: (source: string) =>\n babelParse(source, buildBabelOptions(['jsx', 'typescript'])),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,qBACJ,kBACmB;CACnB,YAAY;CACZ,YAAY;CACZ,6BAA6B;CAC7B,4BAA4B;CAC5B,WAAW;CACX,QAAQ;CACR,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA,CAAC,oBAAoB,EAAE,UAAU,SAAS,CAAC;EAC3C;EACA;EACA,GAAG;CACL;AACF;;AAQA,MAAa,mBAAiC,EAC5C,QAAQ,WACNA,MAAW,QAAQ,kBAAkB,CAAC,YAAY,CAAC,CAAC,EACxD;;AAGA,MAAa,gBAA8B,EACzC,QAAQ,WACNA,MAAW,QAAQ,kBAAkB,CAAC,OAAO,YAAY,CAAC,CAAC,EAC/D"}
@@ -1,8 +1,8 @@
1
1
  import { SERVER_CAPABLE_PACKAGES } from "./utils/constants.mjs";
2
2
  import { extractBabelContentForComponents } from "./babelProcessor.mjs";
3
+ import { parse } from "@babel/parser";
3
4
  import { readFileSync, writeFileSync } from "node:fs";
4
5
  import { detectFormatCommand } from "@intlayer/engine/cli";
5
- import { parse } from "@babel/parser";
6
6
  import { execSync } from "node:child_process";
7
7
  import _traverse from "@babel/traverse";
8
8
  import * as t from "@babel/types";
@@ -0,0 +1,12 @@
1
+ //#region src/babelParser.d.ts
2
+ /** A parser object accepted by `recast.parse`'s `parser` option. */
3
+ type RecastParser = {
4
+ parse: (source: string) => unknown;
5
+ };
6
+ /** Drop-in replacement for `recast/parsers/typescript` (TS without JSX). */
7
+ declare const typescriptParser: RecastParser;
8
+ /** Drop-in replacement for `recast/parsers/babel-ts` (TS *and* JSX). */
9
+ declare const babelTsParser: RecastParser;
10
+ //#endregion
11
+ export { RecastParser, babelTsParser, typescriptParser };
12
+ //# sourceMappingURL=babelParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babelParser.d.ts","names":[],"sources":["../../src/babelParser.ts"],"mappings":";;KAuDY;EACV,QAAQ;;;cAIG,kBAAkB;;cAMlB,eAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/babel",
3
- "version": "9.0.0-canary.19",
3
+ "version": "9.0.0-canary.20",
4
4
  "private": false,
5
5
  "description": "A Babel plugin for Intlayer that transforms declaration files and provides internationalization features during the build process according to the Intlayer configuration.",
6
6
  "keywords": [
@@ -41,10 +41,10 @@
41
41
  "require": "./dist/cjs/index.cjs",
42
42
  "import": "./dist/esm/index.mjs"
43
43
  },
44
- "./recastBabelParser": {
45
- "types": "./dist/types/recastBabelParser.d.ts",
46
- "require": "./dist/cjs/recastBabelParser.cjs",
47
- "import": "./dist/esm/recastBabelParser.mjs"
44
+ "./babelParser": {
45
+ "types": "./dist/types/babelParser.d.ts",
46
+ "require": "./dist/cjs/babelParser.cjs",
47
+ "import": "./dist/esm/babelParser.mjs"
48
48
  },
49
49
  "./package.json": "./package.json"
50
50
  },
@@ -53,8 +53,8 @@
53
53
  "types": "dist/types/index.d.ts",
54
54
  "typesVersions": {
55
55
  "*": {
56
- "recastBabelParser": [
57
- "./dist/types/recastBabelParser.d.ts"
56
+ "babelParser": [
57
+ "./dist/types/babelParser.d.ts"
58
58
  ],
59
59
  "package.json": [
60
60
  "./package.json"
@@ -89,12 +89,12 @@
89
89
  "@babel/plugin-syntax-jsx": "8.0.1",
90
90
  "@babel/traverse": "8.0.4",
91
91
  "@babel/types": "8.0.4",
92
- "@intlayer/config": "9.0.0-canary.19",
93
- "@intlayer/core": "9.0.0-canary.19",
94
- "@intlayer/dictionaries-entry": "9.0.0-canary.19",
95
- "@intlayer/engine": "9.0.0-canary.19",
96
- "@intlayer/types": "9.0.0-canary.19",
97
- "@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.19"
92
+ "@intlayer/config": "9.0.0-canary.20",
93
+ "@intlayer/core": "9.0.0-canary.20",
94
+ "@intlayer/dictionaries-entry": "9.0.0-canary.20",
95
+ "@intlayer/engine": "9.0.0-canary.20",
96
+ "@intlayer/types": "9.0.0-canary.20",
97
+ "@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.20"
98
98
  },
99
99
  "devDependencies": {
100
100
  "@babel/plugin-syntax-jsx": "8.0.1",
@@ -112,8 +112,8 @@
112
112
  "vitest": "4.1.10"
113
113
  },
114
114
  "peerDependencies": {
115
- "@intlayer/svelte-compiler": "9.0.0-canary.19",
116
- "@intlayer/vue-compiler": "9.0.0-canary.19"
115
+ "@intlayer/svelte-compiler": "9.0.0-canary.20",
116
+ "@intlayer/vue-compiler": "9.0.0-canary.20"
117
117
  },
118
118
  "peerDependenciesMeta": {
119
119
  "@intlayer/svelte-compiler": {