@intlayer/babel 6.1.6 → 7.0.0-canary.1

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.
@@ -0,0 +1,25 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ exports.__toESM = __toESM;
@@ -1,282 +1,279 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var babel_plugin_intlayer_exports = {};
30
- __export(babel_plugin_intlayer_exports, {
31
- intlayerBabelPlugin: () => intlayerBabelPlugin
32
- });
33
- module.exports = __toCommonJS(babel_plugin_intlayer_exports);
34
- var t = __toESM(require("@babel/types"));
35
- var import_chokidar = require("@intlayer/chokidar");
36
- var import_config = require("@intlayer/config");
37
- var import_node_path = require("node:path");
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let node_path = require("node:path");
3
+ node_path = require_rolldown_runtime.__toESM(node_path);
4
+ let __intlayer_chokidar = require("@intlayer/chokidar");
5
+ __intlayer_chokidar = require_rolldown_runtime.__toESM(__intlayer_chokidar);
6
+ let __intlayer_config = require("@intlayer/config");
7
+ __intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
8
+
9
+ //#region src/babel-plugin-intlayer.ts
38
10
  const PACKAGE_LIST = [
39
- "intlayer",
40
- "@intlayer/core",
41
- "react-intlayer",
42
- "react-intlayer/client",
43
- "react-intlayer/server",
44
- "next-intlayer",
45
- "next-intlayer/client",
46
- "next-intlayer/server",
47
- "svelte-intlayer",
48
- "vue-intlayer",
49
- "angular-intlayer",
50
- "preact-intlayer",
51
- "solid-intlayer"
11
+ "intlayer",
12
+ "@intlayer/core",
13
+ "react-intlayer",
14
+ "react-intlayer/client",
15
+ "react-intlayer/server",
16
+ "next-intlayer",
17
+ "next-intlayer/client",
18
+ "next-intlayer/server",
19
+ "svelte-intlayer",
20
+ "vue-intlayer",
21
+ "angular-intlayer",
22
+ "preact-intlayer",
23
+ "solid-intlayer"
52
24
  ];
53
25
  const CALLER_LIST = ["useIntlayer", "getIntlayer"];
26
+ /**
27
+ * Packages that support dynamic import
28
+ */
54
29
  const PACKAGE_LIST_DYNAMIC = [
55
- "react-intlayer",
56
- "react-intlayer/client",
57
- "react-intlayer/server",
58
- "next-intlayer",
59
- "next-intlayer/client",
60
- "next-intlayer/server",
61
- "preact-intlayer",
62
- "vue-intlayer",
63
- "solid-intlayer",
64
- "svelte-intlayer",
65
- "angular-intlayer"
30
+ "react-intlayer",
31
+ "react-intlayer/client",
32
+ "react-intlayer/server",
33
+ "next-intlayer",
34
+ "next-intlayer/client",
35
+ "next-intlayer/server",
36
+ "preact-intlayer",
37
+ "vue-intlayer",
38
+ "solid-intlayer",
39
+ "svelte-intlayer",
40
+ "angular-intlayer"
66
41
  ];
67
42
  const STATIC_IMPORT_FUNCTION = {
68
- getIntlayer: "getDictionary",
69
- useIntlayer: "useDictionary"
70
- };
71
- const FETCH_IMPORT_FUNCTION = {
72
- useIntlayer: "useDictionaryDynamic"
73
- };
74
- const DYNAMIC_IMPORT_FUNCTION = {
75
- useIntlayer: "useDictionaryDynamic"
43
+ getIntlayer: "getDictionary",
44
+ useIntlayer: "useDictionary"
76
45
  };
77
- const makeIdent = (key) => {
78
- const hash = (0, import_chokidar.getFileHash)(key);
79
- return t.identifier(`_${hash}`);
46
+ const DYNAMIC_IMPORT_FUNCTION = { useIntlayer: "useDictionaryDynamic" };
47
+ /**
48
+ * Replicates the xxHash64 → Base-62 algorithm used by the SWC version
49
+ * and prefixes an underscore so the generated identifiers never collide
50
+ * with user-defined ones.
51
+ */
52
+ const makeIdent = (key, t) => {
53
+ const hash = (0, __intlayer_chokidar.getFileHash)(key);
54
+ return t.identifier(`_${hash}`);
80
55
  };
81
56
  const computeImport = (fromFile, dictionariesDir, dynamicDictionariesDir, fetchDictionariesDir, key, importMode) => {
82
- let relativePath = (0, import_node_path.join)(dictionariesDir, `${key}.json`);
83
- if (importMode === "live") {
84
- relativePath = (0, import_node_path.join)(fetchDictionariesDir, `${key}.mjs`);
85
- }
86
- if (importMode === "dynamic") {
87
- relativePath = (0, import_node_path.join)(dynamicDictionariesDir, `${key}.mjs`);
88
- }
89
- let rel = (0, import_node_path.relative)((0, import_node_path.dirname)(fromFile), relativePath);
90
- rel = (0, import_config.normalizePath)(rel);
91
- if (!rel.startsWith("./") && !rel.startsWith("../")) {
92
- rel = `./${rel}`;
93
- }
94
- return rel;
57
+ let relativePath = (0, node_path.join)(dictionariesDir, `${key}.json`);
58
+ if (importMode === "live") relativePath = (0, node_path.join)(fetchDictionariesDir, `${key}.mjs`);
59
+ if (importMode === "dynamic") relativePath = (0, node_path.join)(dynamicDictionariesDir, `${key}.mjs`);
60
+ let rel = (0, node_path.relative)((0, node_path.dirname)(fromFile), relativePath);
61
+ rel = (0, __intlayer_config.normalizePath)(rel);
62
+ if (!rel.startsWith("./") && !rel.startsWith("../")) rel = `./${rel}`;
63
+ return rel;
95
64
  };
96
- const intlayerBabelPlugin = () => {
97
- return {
98
- name: "babel-plugin-intlayer-transform",
99
- pre() {
100
- this._newStaticImports = /* @__PURE__ */ new Map();
101
- this._newDynamicImports = /* @__PURE__ */ new Map();
102
- this._isIncluded = true;
103
- this._hasValidImport = false;
104
- this._isDictEntry = false;
105
- this._useDynamicHelpers = false;
106
- const filename = this.file.opts.filename;
107
- if (this.opts.filesList && filename) {
108
- const isIncluded = this.opts.filesList.includes(filename);
109
- if (!isIncluded) {
110
- this._isIncluded = false;
111
- return;
112
- }
113
- }
114
- },
115
- visitor: {
116
- /* 0. If this file *is* the dictionaries entry, short-circuit: export {} */
117
- Program: {
118
- enter(programPath, state) {
119
- const filename = state.file.opts.filename;
120
- if (state.opts.replaceDictionaryEntry && filename === state.opts.dictionariesEntryPath) {
121
- state._isDictEntry = true;
122
- programPath.node.body = [
123
- t.exportDefaultDeclaration(t.objectExpression([]))
124
- ];
125
- programPath.stop();
126
- }
127
- },
128
- /* 3. After full traversal, inject the JSON dictionary imports. */
129
- exit(programPath, state) {
130
- if (state._isDictEntry) return;
131
- if (!state._hasValidImport) return;
132
- if (!state._isIncluded) return;
133
- const file = state.file.opts.filename;
134
- const dictionariesDir = state.opts.dictionariesDir;
135
- const dynamicDictionariesDir = state.opts.dynamicDictionariesDir;
136
- const fetchDictionariesDir = state.opts.fetchDictionariesDir;
137
- const imports = [];
138
- for (const [key, ident] of state._newStaticImports) {
139
- const rel = computeImport(
140
- file,
141
- dictionariesDir,
142
- dynamicDictionariesDir,
143
- fetchDictionariesDir,
144
- key,
145
- "static"
146
- );
147
- const importDeclarationNode = t.importDeclaration(
148
- [t.importDefaultSpecifier(t.identifier(ident.name))],
149
- t.stringLiteral(rel)
150
- );
151
- importDeclarationNode.attributes = [
152
- t.importAttribute(t.identifier("type"), t.stringLiteral("json"))
153
- ];
154
- imports.push(importDeclarationNode);
155
- }
156
- for (const [key, ident] of state._newDynamicImports) {
157
- const modeForThisIdent = ident.name.endsWith(
158
- "_fetch"
159
- ) ? "live" : "dynamic";
160
- const rel = computeImport(
161
- file,
162
- dictionariesDir,
163
- dynamicDictionariesDir,
164
- fetchDictionariesDir,
165
- key,
166
- modeForThisIdent
167
- );
168
- imports.push(
169
- t.importDeclaration(
170
- [t.importDefaultSpecifier(t.identifier(ident.name))],
171
- t.stringLiteral(rel)
172
- )
173
- );
174
- }
175
- if (!imports.length) return;
176
- const bodyPaths = programPath.get("body");
177
- let insertPos = 0;
178
- for (const stmtPath of bodyPaths) {
179
- const stmt = stmtPath.node;
180
- if (t.isExpressionStatement(stmt) && t.isStringLiteral(stmt.expression) && !stmt.expression.value.startsWith("import") && !stmt.expression.value.startsWith("require")) {
181
- insertPos += 1;
182
- } else {
183
- break;
184
- }
185
- }
186
- programPath.node.body.splice(insertPos, 0, ...imports);
187
- }
188
- },
189
- /* 1. Inspect *every* intlayer import. */
190
- ImportDeclaration(path, state) {
191
- if (state._isDictEntry) return;
192
- const src = path.node.source.value;
193
- if (!PACKAGE_LIST.includes(src)) return;
194
- state._hasValidImport = true;
195
- for (const spec of path.node.specifiers) {
196
- if (!t.isImportSpecifier(spec)) continue;
197
- const importedName = t.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value;
198
- const importMode = state.opts.importMode;
199
- const shouldUseDynamicHelpers = (importMode === "dynamic" || importMode === "live") && PACKAGE_LIST_DYNAMIC.includes(src);
200
- if (shouldUseDynamicHelpers) {
201
- state._useDynamicHelpers = true;
202
- }
203
- let helperMap;
204
- if (shouldUseDynamicHelpers) {
205
- helperMap = {
206
- ...STATIC_IMPORT_FUNCTION,
207
- ...DYNAMIC_IMPORT_FUNCTION
208
- };
209
- } else {
210
- helperMap = STATIC_IMPORT_FUNCTION;
211
- }
212
- const newIdentifier = helperMap[importedName];
213
- if (newIdentifier) {
214
- spec.imported = t.identifier(newIdentifier);
215
- }
216
- }
217
- },
218
- /* 2. Replace calls: useIntlayer("foo") → useDictionary(_hash) or useDictionaryDynamic(_hash, "foo") */
219
- CallExpression(path, state) {
220
- if (state._isDictEntry) return;
221
- const callee = path.node.callee;
222
- if (!t.isIdentifier(callee)) return;
223
- if (!CALLER_LIST.includes(callee.name)) return;
224
- state._hasValidImport = true;
225
- const arg = path.node.arguments[0];
226
- if (!arg || !t.isStringLiteral(arg)) return;
227
- const key = arg.value;
228
- const importMode = state.opts.importMode;
229
- const isUseIntlayer = callee.name === "useIntlayer";
230
- const useDynamicHelpers = Boolean(state._useDynamicHelpers);
231
- let perCallMode = "static";
232
- if (isUseIntlayer && useDynamicHelpers) {
233
- if (importMode === "dynamic") {
234
- perCallMode = "dynamic";
235
- } else if (importMode === "live") {
236
- const liveKeys = state.opts.liveSyncKeys ?? [];
237
- perCallMode = liveKeys.includes(key) ? "live" : "dynamic";
238
- }
239
- }
240
- let ident;
241
- if (perCallMode === "live") {
242
- let dynamicIdent = state._newDynamicImports.get(key);
243
- if (!dynamicIdent) {
244
- const hash = (0, import_chokidar.getFileHash)(key);
245
- dynamicIdent = t.identifier(`_${hash}_fetch`);
246
- state._newDynamicImports.set(key, dynamicIdent);
247
- }
248
- ident = dynamicIdent;
249
- path.node.arguments = [
250
- t.identifier(ident.name),
251
- ...path.node.arguments
252
- ];
253
- } else if (perCallMode === "dynamic") {
254
- let dynamicIdent = state._newDynamicImports.get(key);
255
- if (!dynamicIdent) {
256
- const hash = (0, import_chokidar.getFileHash)(key);
257
- dynamicIdent = t.identifier(`_${hash}_dyn`);
258
- state._newDynamicImports.set(key, dynamicIdent);
259
- }
260
- ident = dynamicIdent;
261
- path.node.arguments = [
262
- t.identifier(ident.name),
263
- ...path.node.arguments
264
- ];
265
- } else {
266
- let staticIdent = state._newStaticImports.get(key);
267
- if (!staticIdent) {
268
- staticIdent = makeIdent(key);
269
- state._newStaticImports.set(key, staticIdent);
270
- }
271
- ident = staticIdent;
272
- path.node.arguments[0] = t.identifier(ident.name);
273
- }
274
- }
275
- }
276
- };
65
+ /**
66
+ * Babel plugin that transforms Intlayer function calls and auto-imports dictionaries.
67
+ *
68
+ * This plugin transforms calls to `useIntlayer()` and `getIntlayer()` from various Intlayer
69
+ * packages into optimized dictionary access patterns, automatically importing the required
70
+ * dictionary files based on the configured import mode.
71
+ *
72
+ * ## Supported Input Patterns
73
+ *
74
+ * The plugin recognizes these function calls:
75
+ *
76
+ * ```ts
77
+ * // useIntlayer
78
+ * import { useIntlayer } from 'react-intlayer';
79
+ * import { useIntlayer } from 'next-intlayer';
80
+ *
81
+ * // getIntlayer
82
+ * import { getIntlayer } from 'intlayer';
83
+ *
84
+ * // Usage
85
+ * const content = useIntlayer('app');
86
+ * const content = getIntlayer('app');
87
+ * ```
88
+ *
89
+ * ## Transformation Modes
90
+ *
91
+ * ### Static Mode (default: `importMode = "static"`)
92
+ *
93
+ * Imports JSON dictionaries directly and replaces function calls with dictionary access:
94
+ *
95
+ * **Output:**
96
+ * ```ts
97
+ * import _dicHash from '../../.intlayer/dictionaries/app.json' with { type: 'json' };
98
+ * import { useDictionary as useIntlayer } from 'react-intlayer';
99
+ * import { getDictionary as getIntlayer } from 'intlayer';
100
+ *
101
+ * const content1 = useIntlayer(_dicHash);
102
+ * const content2 = getIntlayer(_dicHash);
103
+ * ```
104
+ *
105
+ * ### Dynamic Mode (`importMode = "dynamic"`)
106
+ *
107
+ * Uses dynamic dictionary loading with Suspense support:
108
+ *
109
+ * **Output:**
110
+ * ```ts
111
+ * import _dicHash from '../../.intlayer/dictionaries/app.json' with { type: 'json' };
112
+ * import _dicHash_dyn from '../../.intlayer/dynamic_dictionaries/app.mjs';
113
+ * import { useDictionaryDynamic as useIntlayer } from 'react-intlayer';
114
+ * import { getDictionary as getIntlayer } from 'intlayer';
115
+ *
116
+ * const content1 = useIntlayer(_dicHash_dyn, 'app');
117
+ * const content2 = getIntlayer(_dicHash);
118
+ * ```
119
+ *
120
+ * ### Live Mode (`importMode = "live"`)
121
+ *
122
+ * Uses live-based dictionary loading for remote dictionaries:
123
+ *
124
+ * **Output if `liveSyncKeys` includes the key:**
125
+ * ```ts
126
+ * import _dicHash from '../../.intlayer/dictionaries/app.json' with { type: 'json' };
127
+ * import _dicHash_fetch from '../../.intlayer/fetch_dictionaries/app.mjs';
128
+ * import { useDictionaryDynamic as useIntlayer } from 'react-intlayer';
129
+ * import { getDictionary as getIntlayer } from 'intlayer';
130
+ *
131
+ * const content1 = useIntlayer(_dicHash_fetch, "app");
132
+ * const content2 = getIntlayer(_dicHash);
133
+ * ```
134
+ *
135
+ * > If `liveSyncKeys` does not include the key, the plugin will fallback to the dynamic impor
136
+ *
137
+ * ```ts
138
+ * import _dicHash from '../../.intlayer/dictionaries/app.json' with { type: 'json' };
139
+ * import _dicHash_dyn from '../../.intlayer/dynamic_dictionaries/app.mjs';
140
+ * import { useDictionaryDynamic as useIntlayer } from 'react-intlayer';
141
+ * import { getDictionary as getIntlayer } from 'intlayer';
142
+ *
143
+ * const content1 = useIntlayer(_dicHash_dyn, 'app');
144
+ * const content2 = getIntlayer(_dicHash);
145
+ * ```
146
+ */
147
+ const intlayerBabelPlugin = (babel) => {
148
+ const { types: t } = babel;
149
+ return {
150
+ name: "babel-plugin-intlayer-transform",
151
+ pre() {
152
+ this._newStaticImports = /* @__PURE__ */ new Map();
153
+ this._newDynamicImports = /* @__PURE__ */ new Map();
154
+ this._isIncluded = true;
155
+ this._hasValidImport = false;
156
+ this._isDictEntry = false;
157
+ this._useDynamicHelpers = false;
158
+ const filename = this.file.opts.filename;
159
+ if (this.opts.filesList && filename) {
160
+ if (!this.opts.filesList.includes(filename)) {
161
+ this._isIncluded = false;
162
+ return;
163
+ }
164
+ }
165
+ },
166
+ visitor: {
167
+ Program: {
168
+ enter(programPath, state) {
169
+ const filename = state.file.opts.filename;
170
+ if (state.opts.replaceDictionaryEntry && filename === state.opts.dictionariesEntryPath) {
171
+ state._isDictEntry = true;
172
+ programPath.node.body = [t.exportDefaultDeclaration(t.objectExpression([]))];
173
+ programPath.stop();
174
+ }
175
+ },
176
+ exit(programPath, state) {
177
+ if (state._isDictEntry) return;
178
+ if (!state._hasValidImport) return;
179
+ if (!state._isIncluded) return;
180
+ const file = state.file.opts.filename;
181
+ const dictionariesDir = state.opts.dictionariesDir;
182
+ const dynamicDictionariesDir = state.opts.dynamicDictionariesDir;
183
+ const fetchDictionariesDir = state.opts.fetchDictionariesDir;
184
+ const imports = [];
185
+ for (const [key, ident] of state._newStaticImports) {
186
+ const rel = computeImport(file, dictionariesDir, dynamicDictionariesDir, fetchDictionariesDir, key, "static");
187
+ const importDeclarationNode = t.importDeclaration([t.importDefaultSpecifier(t.identifier(ident.name))], t.stringLiteral(rel));
188
+ importDeclarationNode.attributes = [t.importAttribute(t.identifier("type"), t.stringLiteral("json"))];
189
+ imports.push(importDeclarationNode);
190
+ }
191
+ for (const [key, ident] of state._newDynamicImports) {
192
+ const rel = computeImport(file, dictionariesDir, dynamicDictionariesDir, fetchDictionariesDir, key, ident.name.endsWith("_fetch") ? "live" : "dynamic");
193
+ imports.push(t.importDeclaration([t.importDefaultSpecifier(t.identifier(ident.name))], t.stringLiteral(rel)));
194
+ }
195
+ if (!imports.length) return;
196
+ const bodyPaths = programPath.get("body");
197
+ let insertPos = 0;
198
+ for (const stmtPath of bodyPaths) {
199
+ const stmt = stmtPath.node;
200
+ if (t.isExpressionStatement(stmt) && t.isStringLiteral(stmt.expression) && !stmt.expression.value.startsWith("import") && !stmt.expression.value.startsWith("require")) insertPos += 1;
201
+ else break;
202
+ }
203
+ programPath.node.body.splice(insertPos, 0, ...imports);
204
+ }
205
+ },
206
+ ImportDeclaration(path, state) {
207
+ if (state._isDictEntry) return;
208
+ const src = path.node.source.value;
209
+ if (!PACKAGE_LIST.includes(src)) return;
210
+ state._hasValidImport = true;
211
+ for (const spec of path.node.specifiers) {
212
+ if (!t.isImportSpecifier(spec)) continue;
213
+ const importedName = t.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value;
214
+ const importMode = state.opts.importMode;
215
+ const shouldUseDynamicHelpers = (importMode === "dynamic" || importMode === "live") && PACKAGE_LIST_DYNAMIC.includes(src);
216
+ if (shouldUseDynamicHelpers) state._useDynamicHelpers = true;
217
+ let helperMap;
218
+ if (shouldUseDynamicHelpers) helperMap = {
219
+ ...STATIC_IMPORT_FUNCTION,
220
+ ...DYNAMIC_IMPORT_FUNCTION
221
+ };
222
+ else helperMap = STATIC_IMPORT_FUNCTION;
223
+ const newIdentifier = helperMap[importedName];
224
+ if (newIdentifier) spec.imported = t.identifier(newIdentifier);
225
+ }
226
+ },
227
+ CallExpression(path, state) {
228
+ if (state._isDictEntry) return;
229
+ const callee = path.node.callee;
230
+ if (!t.isIdentifier(callee)) return;
231
+ if (!CALLER_LIST.includes(callee.name)) return;
232
+ state._hasValidImport = true;
233
+ const arg = path.node.arguments[0];
234
+ if (!arg || !t.isStringLiteral(arg)) return;
235
+ const key = arg.value;
236
+ const importMode = state.opts.importMode;
237
+ const isUseIntlayer = callee.name === "useIntlayer";
238
+ const useDynamicHelpers = Boolean(state._useDynamicHelpers);
239
+ let perCallMode = "static";
240
+ if (isUseIntlayer && useDynamicHelpers) {
241
+ if (importMode === "dynamic") perCallMode = "dynamic";
242
+ else if (importMode === "live") perCallMode = (state.opts.liveSyncKeys ?? []).includes(key) ? "live" : "dynamic";
243
+ }
244
+ let ident;
245
+ if (perCallMode === "live") {
246
+ let dynamicIdent = state._newDynamicImports?.get(key);
247
+ if (!dynamicIdent) {
248
+ const hash = (0, __intlayer_chokidar.getFileHash)(key);
249
+ dynamicIdent = t.identifier(`_${hash}_fetch`);
250
+ state._newDynamicImports?.set(key, dynamicIdent);
251
+ }
252
+ ident = dynamicIdent;
253
+ path.node.arguments = [t.identifier(ident.name), ...path.node.arguments];
254
+ } else if (perCallMode === "dynamic") {
255
+ let dynamicIdent = state._newDynamicImports?.get(key);
256
+ if (!dynamicIdent) {
257
+ const hash = (0, __intlayer_chokidar.getFileHash)(key);
258
+ dynamicIdent = t.identifier(`_${hash}_dyn`);
259
+ state._newDynamicImports?.set(key, dynamicIdent);
260
+ }
261
+ ident = dynamicIdent;
262
+ path.node.arguments = [t.identifier(ident.name), ...path.node.arguments];
263
+ } else {
264
+ let staticIdent = state._newStaticImports?.get(key);
265
+ if (!staticIdent) {
266
+ staticIdent = makeIdent(key, t);
267
+ state._newStaticImports?.set(key, staticIdent);
268
+ }
269
+ ident = staticIdent;
270
+ path.node.arguments[0] = t.identifier(ident.name);
271
+ }
272
+ }
273
+ }
274
+ };
277
275
  };
278
- // Annotate the CommonJS export names for ESM import in node:
279
- 0 && (module.exports = {
280
- intlayerBabelPlugin
281
- });
276
+
277
+ //#endregion
278
+ exports.intlayerBabelPlugin = intlayerBabelPlugin;
282
279
  //# sourceMappingURL=babel-plugin-intlayer.cjs.map