@intlayer/config 8.7.6 → 8.7.7
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/bundle/index.cjs +1 -1
- package/dist/cjs/configFile/buildBrowserConfiguration.cjs +213 -0
- package/dist/cjs/configFile/buildBrowserConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/buildConfigurationFields.cjs +345 -0
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
- package/dist/cjs/logger.cjs.map +1 -1
- package/dist/cjs/utils/alias.cjs.map +1 -1
- package/dist/cjs/utils/cacheDisk.cjs +7 -0
- package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
- package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
- package/dist/cjs/utils/getStorageAttributes.cjs.map +1 -1
- package/dist/esm/bundle/index.mjs +1 -1
- package/dist/esm/configFile/buildBrowserConfiguration.mjs +213 -0
- package/dist/esm/configFile/buildBrowserConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/buildConfigurationFields.mjs +345 -0
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
- package/dist/esm/logger.mjs.map +1 -1
- package/dist/esm/utils/alias.mjs.map +1 -1
- package/dist/esm/utils/cacheDisk.mjs +7 -0
- package/dist/esm/utils/cacheDisk.mjs.map +1 -1
- package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
- package/dist/esm/utils/getStorageAttributes.mjs.map +1 -1
- package/dist/types/configFile/configurationSchema.d.ts +2 -2
- package/package.json +4 -4
|
@@ -101,12 +101,55 @@ const buildContentFields = (systemConfig, customConfiguration) => {
|
|
|
101
101
|
* @returns A fully-defaulted {@link AiConfig}.
|
|
102
102
|
*/
|
|
103
103
|
const buildAiFields = (customConfiguration) => ({
|
|
104
|
+
/**
|
|
105
|
+
* AI configuration
|
|
106
|
+
*/
|
|
104
107
|
provider: customConfiguration?.provider,
|
|
108
|
+
/**
|
|
109
|
+
* API key
|
|
110
|
+
*/
|
|
105
111
|
apiKey: customConfiguration?.apiKey,
|
|
112
|
+
/**
|
|
113
|
+
* API model
|
|
114
|
+
*/
|
|
106
115
|
model: customConfiguration?.model,
|
|
116
|
+
/**
|
|
117
|
+
* Temperature
|
|
118
|
+
*/
|
|
107
119
|
temperature: customConfiguration?.temperature,
|
|
120
|
+
/**
|
|
121
|
+
* Application context
|
|
122
|
+
*
|
|
123
|
+
* Default: undefined
|
|
124
|
+
*
|
|
125
|
+
* The application context.
|
|
126
|
+
*
|
|
127
|
+
* Example: `'My application context'`
|
|
128
|
+
*
|
|
129
|
+
* Note: Can be used to provide additional context about the application to the AI model. You can add more rules (e.g. "You should not transform urls").
|
|
130
|
+
*/
|
|
108
131
|
applicationContext: customConfiguration?.applicationContext,
|
|
132
|
+
/**
|
|
133
|
+
* Base URL for the AI API
|
|
134
|
+
*
|
|
135
|
+
* Default: undefined
|
|
136
|
+
*
|
|
137
|
+
* The base URL for the AI API.
|
|
138
|
+
*
|
|
139
|
+
* Example: `'http://localhost:5000'`
|
|
140
|
+
*
|
|
141
|
+
* Note: Can be used to point to a local, or custom AI API endpoint.
|
|
142
|
+
*/
|
|
109
143
|
baseURL: customConfiguration?.baseURL,
|
|
144
|
+
/**
|
|
145
|
+
* Data serialization
|
|
146
|
+
*
|
|
147
|
+
* Options:
|
|
148
|
+
* - "json": The industry standard. Highly reliable and structured, but consumes more tokens.
|
|
149
|
+
* - "toon": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON
|
|
150
|
+
*
|
|
151
|
+
* Default: `"json"`
|
|
152
|
+
*/
|
|
110
153
|
dataSerialization: customConfiguration?.dataSerialization
|
|
111
154
|
});
|
|
112
155
|
/**
|
|
@@ -116,15 +159,128 @@ const buildAiFields = (customConfiguration) => ({
|
|
|
116
159
|
* @returns A fully-defaulted {@link BuildConfig}.
|
|
117
160
|
*/
|
|
118
161
|
const buildBuildFields = (customConfiguration) => ({
|
|
162
|
+
/**
|
|
163
|
+
* Indicates the mode of the build
|
|
164
|
+
*
|
|
165
|
+
* Default: 'auto'
|
|
166
|
+
*
|
|
167
|
+
* If 'auto', the build will be enabled automatically when the application is built.
|
|
168
|
+
* If 'manual', the build will be set only when the build command is executed.
|
|
169
|
+
*
|
|
170
|
+
* Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.
|
|
171
|
+
*/
|
|
119
172
|
mode: customConfiguration?.mode ?? "auto",
|
|
173
|
+
/**
|
|
174
|
+
* Indicates if the build should be optimized
|
|
175
|
+
*
|
|
176
|
+
* Default: process.env.NODE_ENV === 'production'
|
|
177
|
+
*
|
|
178
|
+
* If true, the build will be optimized.
|
|
179
|
+
* If false, the build will not be optimized.
|
|
180
|
+
*
|
|
181
|
+
* Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.
|
|
182
|
+
* All imports will stay as static import to avoid async processing when loading the dictionaries.
|
|
183
|
+
*
|
|
184
|
+
* Note:
|
|
185
|
+
* - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.
|
|
186
|
+
* - Intlayer will replace all call of `getIntlayer` with `getDictionary`.
|
|
187
|
+
* - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
188
|
+
* - In most cases, "dynamic" will be used for React applications, "async" for Vue.js applications.
|
|
189
|
+
* - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
|
|
190
|
+
*/
|
|
120
191
|
optimize: customConfiguration?.optimize,
|
|
192
|
+
/**
|
|
193
|
+
* Indicates the mode of import to use for the dictionaries.
|
|
194
|
+
*
|
|
195
|
+
* Available modes:
|
|
196
|
+
* - "static": The dictionaries are imported statically.
|
|
197
|
+
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.
|
|
198
|
+
* - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
|
|
199
|
+
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
|
|
200
|
+
* - "live": The dictionaries are imported dynamically using the live sync API.
|
|
201
|
+
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
|
|
202
|
+
* Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as "dynamic" mode.
|
|
203
|
+
*
|
|
204
|
+
* Default: "static"
|
|
205
|
+
*
|
|
206
|
+
* By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.
|
|
207
|
+
*
|
|
208
|
+
* Note:
|
|
209
|
+
* - Dynamic imports rely on Suspense and may slightly impact rendering performance.
|
|
210
|
+
* - If disabled all locales will be loaded at once, even if they are not used.
|
|
211
|
+
* - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
212
|
+
* - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
|
|
213
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
214
|
+
* - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.
|
|
215
|
+
* - The "live" allows to sync the dictionaries to the live sync server.
|
|
216
|
+
*
|
|
217
|
+
* @deprecated Use `dictionary.importMode` instead.
|
|
218
|
+
*/
|
|
121
219
|
importMode: customConfiguration?.importMode,
|
|
220
|
+
/**
|
|
221
|
+
* Minify the dictionaries to reduce the bundle size.
|
|
222
|
+
*
|
|
223
|
+
* Default: false
|
|
224
|
+
*
|
|
225
|
+
* Note:
|
|
226
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
227
|
+
* - This option will be ignore if `editor.enabled` is true.
|
|
228
|
+
* - If there is edge cases where the minification is not working properly, the dictionary will be not minified.
|
|
229
|
+
*/
|
|
122
230
|
minify: customConfiguration?.minify ?? false,
|
|
231
|
+
/**
|
|
232
|
+
* Purge the unused keys in a dictionaries
|
|
233
|
+
*
|
|
234
|
+
* Default: false
|
|
235
|
+
*
|
|
236
|
+
* Note:
|
|
237
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
238
|
+
* - This option will be ignored if `editor.enabled` is true.
|
|
239
|
+
*/
|
|
123
240
|
purge: customConfiguration?.purge ?? false,
|
|
241
|
+
/**
|
|
242
|
+
* Pattern to traverse the code to optimize.
|
|
243
|
+
*
|
|
244
|
+
* Allows to avoid to traverse the code that is not relevant to the optimization.
|
|
245
|
+
* Improve build performance.
|
|
246
|
+
*
|
|
247
|
+
* Default: ['**\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\/node_modules/**']
|
|
248
|
+
*
|
|
249
|
+
* Example: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}']`
|
|
250
|
+
*
|
|
251
|
+
* Note:
|
|
252
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
253
|
+
* - Use glob pattern.
|
|
254
|
+
*/
|
|
124
255
|
traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,
|
|
256
|
+
/**
|
|
257
|
+
* Output format of the dictionaries
|
|
258
|
+
*
|
|
259
|
+
* Can be set on large projects to improve build performance.
|
|
260
|
+
*
|
|
261
|
+
* Default: ['cjs', 'esm']
|
|
262
|
+
*
|
|
263
|
+
* The output format of the dictionaries. It can be either 'cjs' or 'esm'.
|
|
264
|
+
* - 'cjs': The dictionaries are outputted as CommonJS modules.
|
|
265
|
+
* - 'esm': The dictionaries are outputted as ES modules.
|
|
266
|
+
*/
|
|
125
267
|
outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,
|
|
268
|
+
/**
|
|
269
|
+
* Cache
|
|
270
|
+
*/
|
|
126
271
|
cache: customConfiguration?.cache ?? true,
|
|
272
|
+
/**
|
|
273
|
+
* Require function
|
|
274
|
+
*/
|
|
127
275
|
require: customConfiguration?.require,
|
|
276
|
+
/**
|
|
277
|
+
* Indicates if the build should check TypeScript types
|
|
278
|
+
*
|
|
279
|
+
* Default: `false`
|
|
280
|
+
*
|
|
281
|
+
* If true, the build will check TypeScript types and log errors.
|
|
282
|
+
* Note: This can slow down the build.
|
|
283
|
+
*/
|
|
128
284
|
checkTypes: customConfiguration?.checkTypes ?? false
|
|
129
285
|
});
|
|
130
286
|
/**
|
|
@@ -134,12 +290,108 @@ const buildBuildFields = (customConfiguration) => ({
|
|
|
134
290
|
* @returns A fully-defaulted {@link CompilerConfig}.
|
|
135
291
|
*/
|
|
136
292
|
const buildCompilerFields = (customConfiguration) => ({
|
|
293
|
+
/**
|
|
294
|
+
* Indicates if the compiler should be enabled
|
|
295
|
+
*/
|
|
137
296
|
enabled: customConfiguration?.enabled ?? true,
|
|
297
|
+
/**
|
|
298
|
+
* Prefix for the extracted dictionary keys
|
|
299
|
+
*/
|
|
138
300
|
dictionaryKeyPrefix: customConfiguration?.dictionaryKeyPrefix ?? "",
|
|
301
|
+
/**
|
|
302
|
+
* Pattern to traverse the code to optimize.
|
|
303
|
+
*
|
|
304
|
+
* @deprecated use `build.traversePattern` instead
|
|
305
|
+
*/
|
|
139
306
|
transformPattern: customConfiguration?.transformPattern,
|
|
307
|
+
/**
|
|
308
|
+
* Pattern to exclude from the optimization.
|
|
309
|
+
*
|
|
310
|
+
* @deprecated use `build.traversePattern` instead
|
|
311
|
+
*/
|
|
140
312
|
excludePattern: customConfiguration?.excludePattern,
|
|
313
|
+
/**
|
|
314
|
+
* Defines the output files path. Replaces `outputDir`.
|
|
315
|
+
*
|
|
316
|
+
* - `./` paths are resolved relative to the component directory.
|
|
317
|
+
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
318
|
+
*
|
|
319
|
+
* - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
|
|
320
|
+
*
|
|
321
|
+
* @example:
|
|
322
|
+
* ```ts
|
|
323
|
+
* {
|
|
324
|
+
* // Create Multilingual .content.ts files close to the component
|
|
325
|
+
* output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
326
|
+
*
|
|
327
|
+
* // output: './{{fileName}}{{extension}}', // Equivalent using template string
|
|
328
|
+
* }
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* ```ts
|
|
332
|
+
* {
|
|
333
|
+
* // Create centralize per-locale JSON at the root of the project
|
|
334
|
+
* output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
335
|
+
*
|
|
336
|
+
* // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
|
|
337
|
+
* }
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* ```ts
|
|
341
|
+
* {
|
|
342
|
+
* // Create per-locale JSON files with locale-specific output paths
|
|
343
|
+
* output: {
|
|
344
|
+
* en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,
|
|
345
|
+
* fr: '{{fileName}}.{{locale}}.content.json',
|
|
346
|
+
* es: false, // skip this locale
|
|
347
|
+
* },
|
|
348
|
+
* }
|
|
349
|
+
* ```
|
|
350
|
+
*
|
|
351
|
+
* Variable list:
|
|
352
|
+
* - `fileName`: The name of the file.
|
|
353
|
+
* - `key`: The key of the content.
|
|
354
|
+
* - `locale`: The locale of the content.
|
|
355
|
+
* - `extension`: The extension of the file.
|
|
356
|
+
* - `componentFileName`: The name of the component file.
|
|
357
|
+
* - `componentExtension`: The extension of the component file.
|
|
358
|
+
* - `format`: The format of the dictionary.
|
|
359
|
+
* - `componentFormat`: The format of the component dictionary.
|
|
360
|
+
* - `componentDirPath`: The directory path of the component.
|
|
361
|
+
*/
|
|
141
362
|
output: customConfiguration?.output,
|
|
363
|
+
/**
|
|
364
|
+
* Indicates if the metadata should be saved in the file.
|
|
365
|
+
*
|
|
366
|
+
* If true, the compiler will not save the metadata of the dictionaries.
|
|
367
|
+
*
|
|
368
|
+
* If `true`:
|
|
369
|
+
*
|
|
370
|
+
* ```json
|
|
371
|
+
* {
|
|
372
|
+
* "key": "value"
|
|
373
|
+
* }
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* If `false`:
|
|
377
|
+
*
|
|
378
|
+
* ```json
|
|
379
|
+
* {
|
|
380
|
+
* "key": "value",
|
|
381
|
+
* "content": {
|
|
382
|
+
* "key": "value"
|
|
383
|
+
* }
|
|
384
|
+
* }
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* Default: `false`
|
|
388
|
+
*
|
|
389
|
+
* Note: Useful if used with loadJSON plugin
|
|
390
|
+
*/
|
|
142
391
|
noMetadata: customConfiguration?.noMetadata ?? false,
|
|
392
|
+
/**
|
|
393
|
+
* Indicates if the components should be saved after being transformed.
|
|
394
|
+
*/
|
|
143
395
|
saveComponents: customConfiguration?.saveComponents ?? false
|
|
144
396
|
});
|
|
145
397
|
/**
|
|
@@ -151,18 +403,111 @@ const buildCompilerFields = (customConfiguration) => ({
|
|
|
151
403
|
const buildDictionaryFields = (customConfiguration) => {
|
|
152
404
|
const contentAutoTransformation = customConfiguration?.contentAutoTransformation ?? false;
|
|
153
405
|
return {
|
|
406
|
+
/**
|
|
407
|
+
* Indicate how the dictionary should be filled using AI.
|
|
408
|
+
*
|
|
409
|
+
* Default: `true`
|
|
410
|
+
*
|
|
411
|
+
* - If `true`, will consider the `compiler.output` field.
|
|
412
|
+
* - If `false`, will skip the fill process.
|
|
413
|
+
*
|
|
414
|
+
* - `./` paths are resolved relative to the component directory.
|
|
415
|
+
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
416
|
+
*
|
|
417
|
+
* - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.
|
|
418
|
+
*
|
|
419
|
+
* Example:
|
|
420
|
+
* ```ts
|
|
421
|
+
* {
|
|
422
|
+
* // Create Multilingual .content.ts files close to the component
|
|
423
|
+
* fill: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
424
|
+
*
|
|
425
|
+
* // fill: './{{fileName}}{{extension}}', // Equivalent using template string
|
|
426
|
+
* }
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* ```ts
|
|
430
|
+
* {
|
|
431
|
+
* // Create centralize per-locale JSON at the root of the project
|
|
432
|
+
* fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
433
|
+
*
|
|
434
|
+
* // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
|
|
435
|
+
* }
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* ```ts
|
|
439
|
+
* {
|
|
440
|
+
* // Create custom output based on the locale
|
|
441
|
+
* fill: {
|
|
442
|
+
* en: ({ key }) => `/locales/en/${key}.content.json`,
|
|
443
|
+
* fr: '/locales/fr/{{key}}.content.json',
|
|
444
|
+
* es: false,
|
|
445
|
+
* de: true,
|
|
446
|
+
* },
|
|
447
|
+
* }
|
|
448
|
+
* ```
|
|
449
|
+
*
|
|
450
|
+
*
|
|
451
|
+
* Variable list:
|
|
452
|
+
* - `fileName`: The name of the file.
|
|
453
|
+
* - `key`: The key of the content.
|
|
454
|
+
* - `locale`: The locale of the content.
|
|
455
|
+
* - `extension`: The extension of the file.
|
|
456
|
+
* - `componentFileName`: The name of the component file.
|
|
457
|
+
* - `componentExtension`: The extension of the component file.
|
|
458
|
+
* - `format`: The format of the dictionary.
|
|
459
|
+
* - `componentFormat`: The format of the component dictionary.
|
|
460
|
+
* - `componentDirPath`: The directory path of the component.
|
|
461
|
+
*/
|
|
154
462
|
fill: customConfiguration?.fill ?? true,
|
|
463
|
+
/**
|
|
464
|
+
* Indicates if the content of the dictionary should be automatically transformed.
|
|
465
|
+
*
|
|
466
|
+
* Default: `false`
|
|
467
|
+
*/
|
|
155
468
|
contentAutoTransformation: typeof contentAutoTransformation === "object" ? {
|
|
156
469
|
markdown: contentAutoTransformation.markdown ?? false,
|
|
157
470
|
html: contentAutoTransformation.html ?? false,
|
|
158
471
|
insertion: contentAutoTransformation.insertion ?? false
|
|
159
472
|
} : contentAutoTransformation,
|
|
473
|
+
/**
|
|
474
|
+
* The location of the dictionary.
|
|
475
|
+
*
|
|
476
|
+
* Default: `"local"`
|
|
477
|
+
*/
|
|
160
478
|
location: customConfiguration?.location ?? "local",
|
|
479
|
+
/**
|
|
480
|
+
* Transform the dictionary in a per-locale dictionary.
|
|
481
|
+
* Each field declared in a per-locale dictionary will be transformed in a translation node.
|
|
482
|
+
* If missing, the dictionary will be treated as a multilingual dictionary.
|
|
483
|
+
*/
|
|
161
484
|
locale: customConfiguration?.locale,
|
|
485
|
+
/**
|
|
486
|
+
* The title of the dictionary.
|
|
487
|
+
*/
|
|
162
488
|
title: customConfiguration?.title,
|
|
489
|
+
/**
|
|
490
|
+
* The description of the dictionary.
|
|
491
|
+
*/
|
|
163
492
|
description: customConfiguration?.description,
|
|
493
|
+
/**
|
|
494
|
+
* Tags to categorize the dictionaries.
|
|
495
|
+
*/
|
|
164
496
|
tags: customConfiguration?.tags,
|
|
497
|
+
/**
|
|
498
|
+
* The priority of the dictionary.
|
|
499
|
+
*/
|
|
165
500
|
priority: customConfiguration?.priority,
|
|
501
|
+
/**
|
|
502
|
+
* Indicates the mode of import to use for the dictionary.
|
|
503
|
+
*
|
|
504
|
+
* Available modes:
|
|
505
|
+
* - "static": The dictionaries are imported statically.
|
|
506
|
+
* - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
|
|
507
|
+
* - "live": The dictionaries are imported dynamically using the live sync API.
|
|
508
|
+
*
|
|
509
|
+
* Default: `"static"`
|
|
510
|
+
*/
|
|
166
511
|
importMode: customConfiguration?.importMode ?? "static"
|
|
167
512
|
};
|
|
168
513
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildConfigurationFields.mjs","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n IntlayerConfig,\n LogFunctions,\n SystemConfig,\n} from '@intlayer/types/config';\nimport {\n BUILD_MODE,\n CACHE,\n MINIFY,\n OUTPUT_FORMAT,\n PURGE,\n TRAVERSE_PATTERN,\n TYPE_CHECKING,\n} from '../defaultValues/build';\nimport {\n COMPILER_DICTIONARY_KEY_PREFIX,\n COMPILER_ENABLED,\n COMPILER_NO_METADATA,\n COMPILER_SAVE_COMPONENTS,\n} from '../defaultValues/compiler';\nimport {\n CODE_DIR,\n CONTENT_DIR,\n EXCLUDED_PATHS,\n FILE_EXTENSIONS,\n WATCH,\n} from '../defaultValues/content';\nimport {\n CONTENT_AUTO_TRANSFORMATION,\n FILL,\n IMPORT_MODE,\n LOCATION,\n} from '../defaultValues/dictionary';\nimport {\n CACHE_DIR,\n CONFIG_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n FETCH_DICTIONARIES_DIR,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TEMP_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n} from '../defaultValues/system';\nimport { getProjectRequire } from '../utils';\nimport {\n buildBrowserConfiguration,\n buildEditorFields,\n buildInternationalizationFields,\n buildLogFields,\n} from './buildBrowserConfiguration';\nimport { intlayerConfigSchema } from './configurationSchema';\n\nexport {\n type BrowserIntlayerConfig,\n buildBrowserConfiguration,\n buildEditorFields,\n buildInternationalizationFields,\n buildLogFields,\n buildRoutingFields,\n extractBrowserConfiguration,\n} from './buildBrowserConfiguration';\n\nlet storedConfiguration: IntlayerConfig;\n\n// ---------------------------------------------------------------------------\n// Server-only field builders (Node.js — not browser-safe)\n// ---------------------------------------------------------------------------\n\n/**\n * Build the `system` section of the Intlayer configuration.\n *\n * Resolves all directory paths (dictionaries, types, cache, …) relative to\n * the project base directory, using Node.js `require.resolve` where available\n * and falling back to `path.join` otherwise.\n *\n * @param baseDir - Project root directory. Defaults to `process.cwd()`.\n * @param customConfiguration - Partial user-supplied system config.\n * @returns A fully-resolved {@link SystemConfig}.\n */\nconst buildSystemFields = (\n baseDir?: string,\n customConfiguration?: Partial<SystemConfig>\n): SystemConfig => {\n const projectBaseDir = baseDir ?? process.cwd();\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n const requireFunction = getProjectRequire(projectBaseDir);\n absolutePath = requireFunction.resolve(pathInput, {\n paths: [projectBaseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(projectBaseDir, pathInput);\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const dictionariesDir = optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n );\n\n return {\n baseDir: projectBaseDir,\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n dictionariesDir,\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n tempDir: optionalJoinBaseDir(customConfiguration?.tempDir ?? TEMP_DIR),\n };\n};\n\n/**\n * Build the `content` section of the Intlayer configuration.\n *\n * Resolves content and code directories relative to the project base using\n * `require.resolve`, falling back to `path.join`.\n *\n * @param systemConfig - Already-built system configuration (provides `baseDir`).\n * @param customConfiguration - Partial user-supplied content config.\n * @returns A fully-resolved {@link ContentConfig}.\n */\nconst buildContentFields = (\n systemConfig: SystemConfig,\n customConfiguration?: Partial<ContentConfig>\n): ContentConfig => {\n const fileExtensions = customConfiguration?.fileExtensions ?? FILE_EXTENSIONS;\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n const requireFunction = getProjectRequire(systemConfig.baseDir);\n absolutePath = requireFunction.resolve(pathInput, {\n paths: [systemConfig.baseDir],\n });\n } catch {\n try {\n absolutePath = require.resolve(pathInput, {\n paths: [systemConfig.baseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(systemConfig.baseDir, pathInput);\n }\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const contentDir = (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n );\n const codeDir = (customConfiguration?.codeDir ?? CODE_DIR).map(\n optionalJoinBaseDir\n );\n\n return {\n fileExtensions,\n contentDir,\n codeDir,\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n watch: customConfiguration?.watch ?? WATCH,\n formatCommand: customConfiguration?.formatCommand,\n };\n};\n\n/**\n * Build the `ai` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied AI config.\n * @returns A fully-defaulted {@link AiConfig}.\n */\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n *\n * Default: undefined\n *\n * The application context.\n *\n * Example: `'My application context'`\n *\n * Note: Can be used to provide additional context about the application to the AI model. You can add more rules (e.g. \"You should not transform urls\").\n */\n applicationContext: customConfiguration?.applicationContext,\n\n /**\n * Base URL for the AI API\n *\n * Default: undefined\n *\n * The base URL for the AI API.\n *\n * Example: `'http://localhost:5000'`\n *\n * Note: Can be used to point to a local, or custom AI API endpoint.\n */\n baseURL: customConfiguration?.baseURL,\n\n /**\n * Data serialization\n *\n * Options:\n * - \"json\": The industry standard. Highly reliable and structured, but consumes more tokens.\n * - \"toon\": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON\n *\n * Default: `\"json\"`\n */\n dataSerialization: customConfiguration?.dataSerialization,\n});\n\n/**\n * Build the `build` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied build config.\n * @returns A fully-defaulted {@link BuildConfig}.\n */\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates the mode of the build\n *\n * Default: 'auto'\n *\n * If 'auto', the build will be enabled automatically when the application is built.\n * If 'manual', the build will be set only when the build command is executed.\n *\n * Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.\n */\n mode: customConfiguration?.mode ?? BUILD_MODE,\n\n /**\n * Indicates if the build should be optimized\n *\n * Default: process.env.NODE_ENV === 'production'\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - In most cases, \"dynamic\" will be used for React applications, \"async\" for Vue.js applications.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: customConfiguration?.optimize,\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If disabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"live\" allows to sync the dictionaries to the live sync server.\n *\n * @deprecated Use `dictionary.importMode` instead.\n */\n importMode: customConfiguration?.importMode,\n\n /**\n * Minify the dictionaries to reduce the bundle size.\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - This option will be ignore if `editor.enabled` is true.\n * - If there is edge cases where the minification is not working properly, the dictionary will be not minified.\n */\n minify: customConfiguration?.minify ?? MINIFY,\n\n /**\n * Purge the unused keys in a dictionaries\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - This option will be ignored if `editor.enabled` is true.\n */\n purge: customConfiguration?.purge ?? PURGE,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * Allows to avoid to traverse the code that is not relevant to the optimization.\n * Improve build performance.\n *\n * Default: ['**\\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,\n\n /**\n * Output format of the dictionaries\n *\n * Can be set on large projects to improve build performance.\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'.\n * - 'cjs': The dictionaries are outputted as CommonJS modules.\n * - 'esm': The dictionaries are outputted as ES modules.\n */\n outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,\n\n /**\n * Cache\n */\n cache: customConfiguration?.cache ?? CACHE,\n\n /**\n * Require function\n */\n require: customConfiguration?.require,\n\n /**\n * Indicates if the build should check TypeScript types\n *\n * Default: `false`\n *\n * If true, the build will check TypeScript types and log errors.\n * Note: This can slow down the build.\n */\n checkTypes: customConfiguration?.checkTypes ?? TYPE_CHECKING,\n});\n\n/**\n * Build the `compiler` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied compiler config.\n * @returns A fully-defaulted {@link CompilerConfig}.\n */\nconst buildCompilerFields = (\n customConfiguration?: Partial<CompilerConfig>\n): CompilerConfig => ({\n /**\n * Indicates if the compiler should be enabled\n */\n enabled: customConfiguration?.enabled ?? COMPILER_ENABLED,\n\n /**\n * Prefix for the extracted dictionary keys\n */\n dictionaryKeyPrefix:\n customConfiguration?.dictionaryKeyPrefix ?? COMPILER_DICTIONARY_KEY_PREFIX,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * @deprecated use `build.traversePattern` instead\n */\n transformPattern: customConfiguration?.transformPattern,\n\n /**\n * Pattern to exclude from the optimization.\n *\n * @deprecated use `build.traversePattern` instead\n */\n excludePattern: customConfiguration?.excludePattern,\n\n /**\n * Defines the output files path. Replaces `outputDir`.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.\n *\n * @example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * output: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // output: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create per-locale JSON files with locale-specific output paths\n * output: {\n * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,\n * fr: '{{fileName}}.{{locale}}.content.json',\n * es: false, // skip this locale\n * },\n * }\n * ```\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n output: customConfiguration?.output,\n\n /**\n * Indicates if the metadata should be saved in the file.\n *\n * If true, the compiler will not save the metadata of the dictionaries.\n *\n * If `true`:\n *\n * ```json\n * {\n * \"key\": \"value\"\n * }\n * ```\n *\n * If `false`:\n *\n * ```json\n * {\n * \"key\": \"value\",\n * \"content\": {\n * \"key\": \"value\"\n * }\n * }\n * ```\n *\n * Default: `false`\n *\n * Note: Useful if used with loadJSON plugin\n */\n noMetadata: customConfiguration?.noMetadata ?? COMPILER_NO_METADATA,\n\n /**\n * Indicates if the components should be saved after being transformed.\n */\n saveComponents:\n customConfiguration?.saveComponents ?? COMPILER_SAVE_COMPONENTS,\n});\n\n/**\n * Build the `dictionary` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied dictionary config.\n * @returns A fully-defaulted {@link DictionaryConfig}.\n */\nconst buildDictionaryFields = (\n customConfiguration?: Partial<DictionaryConfig>\n): DictionaryConfig => {\n const contentAutoTransformation =\n customConfiguration?.contentAutoTransformation ??\n CONTENT_AUTO_TRANSFORMATION;\n\n return {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: `true`\n *\n * - If `true`, will consider the `compiler.output` field.\n * - If `false`, will skip the fill process.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * fill: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // fill: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create custom output based on the locale\n * fill: {\n * en: ({ key }) => `/locales/en/${key}.content.json`,\n * fr: '/locales/fr/{{key}}.content.json',\n * es: false,\n * de: true,\n * },\n * }\n * ```\n *\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * Indicates if the content of the dictionary should be automatically transformed.\n *\n * Default: `false`\n */\n contentAutoTransformation:\n typeof contentAutoTransformation === 'object'\n ? {\n markdown: contentAutoTransformation.markdown ?? false,\n html: contentAutoTransformation.html ?? false,\n insertion: contentAutoTransformation.insertion ?? false,\n }\n : contentAutoTransformation,\n\n /**\n * The location of the dictionary.\n *\n * Default: `\"local\"`\n */\n location: customConfiguration?.location ?? LOCATION,\n\n /**\n * Transform the dictionary in a per-locale dictionary.\n * Each field declared in a per-locale dictionary will be transformed in a translation node.\n * If missing, the dictionary will be treated as a multilingual dictionary.\n */\n locale: customConfiguration?.locale,\n\n /**\n * The title of the dictionary.\n */\n title: customConfiguration?.title,\n\n /**\n * The description of the dictionary.\n */\n description: customConfiguration?.description,\n\n /**\n * Tags to categorize the dictionaries.\n */\n tags: customConfiguration?.tags,\n\n /**\n * The priority of the dictionary.\n */\n priority: customConfiguration?.priority,\n\n /**\n * Indicates the mode of import to use for the dictionary.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n *\n * Default: `\"static\"`\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n };\n};\n\n// ---------------------------------------------------------------------------\n// Main export\n// ---------------------------------------------------------------------------\n\n/**\n * Build the complete Intlayer configuration by merging user-supplied values\n * with defaults.\n *\n * Internally this function:\n * 1. Calls {@link buildBrowserConfiguration} to produce the browser-safe\n * subset (internationalization, routing, editor public fields, log, metadata).\n * 2. Extends the result with full server-side fields:\n * - `internationalization` — adds `requiredLocales` and `strictMode`.\n * - `editor` — adds `clientId` and `clientSecret`.\n * - `log` — adds custom log functions.\n * - `system`, `content`, `ai`, `build`, `compiler`, `dictionary`.\n *\n * @param customConfiguration - Optional user-supplied configuration object.\n * @param baseDir - Project root directory. Defaults to `process.cwd()`.\n * @param logFunctions - Optional custom logging functions.\n * @returns A fully-built {@link IntlayerConfig}.\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string,\n logFunctions?: LogFunctions\n): IntlayerConfig => {\n if (customConfiguration) {\n const result = intlayerConfigSchema.safeParse(customConfiguration);\n\n if (!result.success) {\n const logError = logFunctions?.error ?? console.error;\n\n for (const issue of result.error.issues) {\n logError(`${issue.path.join('.')}: ${issue.message}`);\n }\n }\n }\n\n // build browser-safe config (shared defaults, no Node.js deps)\n const browserConfig = buildBrowserConfiguration(customConfiguration);\n\n // extend shared fields with server-only additions\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log, logFunctions);\n\n // build server-only fields\n const systemConfig = buildSystemFields(baseDir, customConfiguration?.system);\n\n const contentConfig = buildContentFields(\n systemConfig,\n customConfiguration?.content\n );\n\n storedConfiguration = {\n // Shared browser fields\n routing: browserConfig.routing,\n // Full (extended) shared fields\n internationalization: internationalizationConfig,\n editor: editorConfig,\n log: logConfig,\n // Server-only fields\n system: systemConfig,\n content: contentConfig,\n ai: buildAiFields(customConfiguration?.ai),\n build: buildBuildFields(customConfiguration?.build),\n compiler: buildCompilerFields(customConfiguration?.compiler),\n dictionary: buildDictionaryFields(customConfiguration?.dictionary),\n plugins: customConfiguration?.plugins,\n schemas: customConfiguration?.schemas,\n } as IntlayerConfig;\n\n return storedConfiguration;\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"buildConfigurationFields.mjs","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n IntlayerConfig,\n LogFunctions,\n SystemConfig,\n} from '@intlayer/types/config';\nimport {\n BUILD_MODE,\n CACHE,\n MINIFY,\n OUTPUT_FORMAT,\n PURGE,\n TRAVERSE_PATTERN,\n TYPE_CHECKING,\n} from '../defaultValues/build';\nimport {\n COMPILER_DICTIONARY_KEY_PREFIX,\n COMPILER_ENABLED,\n COMPILER_NO_METADATA,\n COMPILER_SAVE_COMPONENTS,\n} from '../defaultValues/compiler';\nimport {\n CODE_DIR,\n CONTENT_DIR,\n EXCLUDED_PATHS,\n FILE_EXTENSIONS,\n WATCH,\n} from '../defaultValues/content';\nimport {\n CONTENT_AUTO_TRANSFORMATION,\n FILL,\n IMPORT_MODE,\n LOCATION,\n} from '../defaultValues/dictionary';\nimport {\n CACHE_DIR,\n CONFIG_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n FETCH_DICTIONARIES_DIR,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TEMP_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n} from '../defaultValues/system';\nimport { getProjectRequire } from '../utils';\nimport {\n buildBrowserConfiguration,\n buildEditorFields,\n buildInternationalizationFields,\n buildLogFields,\n} from './buildBrowserConfiguration';\nimport { intlayerConfigSchema } from './configurationSchema';\n\nexport {\n type BrowserIntlayerConfig,\n buildBrowserConfiguration,\n buildEditorFields,\n buildInternationalizationFields,\n buildLogFields,\n buildRoutingFields,\n extractBrowserConfiguration,\n} from './buildBrowserConfiguration';\n\nlet storedConfiguration: IntlayerConfig;\n\n// ---------------------------------------------------------------------------\n// Server-only field builders (Node.js — not browser-safe)\n// ---------------------------------------------------------------------------\n\n/**\n * Build the `system` section of the Intlayer configuration.\n *\n * Resolves all directory paths (dictionaries, types, cache, …) relative to\n * the project base directory, using Node.js `require.resolve` where available\n * and falling back to `path.join` otherwise.\n *\n * @param baseDir - Project root directory. Defaults to `process.cwd()`.\n * @param customConfiguration - Partial user-supplied system config.\n * @returns A fully-resolved {@link SystemConfig}.\n */\nconst buildSystemFields = (\n baseDir?: string,\n customConfiguration?: Partial<SystemConfig>\n): SystemConfig => {\n const projectBaseDir = baseDir ?? process.cwd();\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n const requireFunction = getProjectRequire(projectBaseDir);\n absolutePath = requireFunction.resolve(pathInput, {\n paths: [projectBaseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(projectBaseDir, pathInput);\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const dictionariesDir = optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n );\n\n return {\n baseDir: projectBaseDir,\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n dictionariesDir,\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n tempDir: optionalJoinBaseDir(customConfiguration?.tempDir ?? TEMP_DIR),\n };\n};\n\n/**\n * Build the `content` section of the Intlayer configuration.\n *\n * Resolves content and code directories relative to the project base using\n * `require.resolve`, falling back to `path.join`.\n *\n * @param systemConfig - Already-built system configuration (provides `baseDir`).\n * @param customConfiguration - Partial user-supplied content config.\n * @returns A fully-resolved {@link ContentConfig}.\n */\nconst buildContentFields = (\n systemConfig: SystemConfig,\n customConfiguration?: Partial<ContentConfig>\n): ContentConfig => {\n const fileExtensions = customConfiguration?.fileExtensions ?? FILE_EXTENSIONS;\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n const requireFunction = getProjectRequire(systemConfig.baseDir);\n absolutePath = requireFunction.resolve(pathInput, {\n paths: [systemConfig.baseDir],\n });\n } catch {\n try {\n absolutePath = require.resolve(pathInput, {\n paths: [systemConfig.baseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(systemConfig.baseDir, pathInput);\n }\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const contentDir = (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n );\n const codeDir = (customConfiguration?.codeDir ?? CODE_DIR).map(\n optionalJoinBaseDir\n );\n\n return {\n fileExtensions,\n contentDir,\n codeDir,\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n watch: customConfiguration?.watch ?? WATCH,\n formatCommand: customConfiguration?.formatCommand,\n };\n};\n\n/**\n * Build the `ai` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied AI config.\n * @returns A fully-defaulted {@link AiConfig}.\n */\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n *\n * Default: undefined\n *\n * The application context.\n *\n * Example: `'My application context'`\n *\n * Note: Can be used to provide additional context about the application to the AI model. You can add more rules (e.g. \"You should not transform urls\").\n */\n applicationContext: customConfiguration?.applicationContext,\n\n /**\n * Base URL for the AI API\n *\n * Default: undefined\n *\n * The base URL for the AI API.\n *\n * Example: `'http://localhost:5000'`\n *\n * Note: Can be used to point to a local, or custom AI API endpoint.\n */\n baseURL: customConfiguration?.baseURL,\n\n /**\n * Data serialization\n *\n * Options:\n * - \"json\": The industry standard. Highly reliable and structured, but consumes more tokens.\n * - \"toon\": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON\n *\n * Default: `\"json\"`\n */\n dataSerialization: customConfiguration?.dataSerialization,\n});\n\n/**\n * Build the `build` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied build config.\n * @returns A fully-defaulted {@link BuildConfig}.\n */\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates the mode of the build\n *\n * Default: 'auto'\n *\n * If 'auto', the build will be enabled automatically when the application is built.\n * If 'manual', the build will be set only when the build command is executed.\n *\n * Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.\n */\n mode: customConfiguration?.mode ?? BUILD_MODE,\n\n /**\n * Indicates if the build should be optimized\n *\n * Default: process.env.NODE_ENV === 'production'\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - In most cases, \"dynamic\" will be used for React applications, \"async\" for Vue.js applications.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: customConfiguration?.optimize,\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If disabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"live\" allows to sync the dictionaries to the live sync server.\n *\n * @deprecated Use `dictionary.importMode` instead.\n */\n importMode: customConfiguration?.importMode,\n\n /**\n * Minify the dictionaries to reduce the bundle size.\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - This option will be ignore if `editor.enabled` is true.\n * - If there is edge cases where the minification is not working properly, the dictionary will be not minified.\n */\n minify: customConfiguration?.minify ?? MINIFY,\n\n /**\n * Purge the unused keys in a dictionaries\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - This option will be ignored if `editor.enabled` is true.\n */\n purge: customConfiguration?.purge ?? PURGE,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * Allows to avoid to traverse the code that is not relevant to the optimization.\n * Improve build performance.\n *\n * Default: ['**\\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,\n\n /**\n * Output format of the dictionaries\n *\n * Can be set on large projects to improve build performance.\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'.\n * - 'cjs': The dictionaries are outputted as CommonJS modules.\n * - 'esm': The dictionaries are outputted as ES modules.\n */\n outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,\n\n /**\n * Cache\n */\n cache: customConfiguration?.cache ?? CACHE,\n\n /**\n * Require function\n */\n require: customConfiguration?.require,\n\n /**\n * Indicates if the build should check TypeScript types\n *\n * Default: `false`\n *\n * If true, the build will check TypeScript types and log errors.\n * Note: This can slow down the build.\n */\n checkTypes: customConfiguration?.checkTypes ?? TYPE_CHECKING,\n});\n\n/**\n * Build the `compiler` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied compiler config.\n * @returns A fully-defaulted {@link CompilerConfig}.\n */\nconst buildCompilerFields = (\n customConfiguration?: Partial<CompilerConfig>\n): CompilerConfig => ({\n /**\n * Indicates if the compiler should be enabled\n */\n enabled: customConfiguration?.enabled ?? COMPILER_ENABLED,\n\n /**\n * Prefix for the extracted dictionary keys\n */\n dictionaryKeyPrefix:\n customConfiguration?.dictionaryKeyPrefix ?? COMPILER_DICTIONARY_KEY_PREFIX,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * @deprecated use `build.traversePattern` instead\n */\n transformPattern: customConfiguration?.transformPattern,\n\n /**\n * Pattern to exclude from the optimization.\n *\n * @deprecated use `build.traversePattern` instead\n */\n excludePattern: customConfiguration?.excludePattern,\n\n /**\n * Defines the output files path. Replaces `outputDir`.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.\n *\n * @example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * output: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // output: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create per-locale JSON files with locale-specific output paths\n * output: {\n * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,\n * fr: '{{fileName}}.{{locale}}.content.json',\n * es: false, // skip this locale\n * },\n * }\n * ```\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n output: customConfiguration?.output,\n\n /**\n * Indicates if the metadata should be saved in the file.\n *\n * If true, the compiler will not save the metadata of the dictionaries.\n *\n * If `true`:\n *\n * ```json\n * {\n * \"key\": \"value\"\n * }\n * ```\n *\n * If `false`:\n *\n * ```json\n * {\n * \"key\": \"value\",\n * \"content\": {\n * \"key\": \"value\"\n * }\n * }\n * ```\n *\n * Default: `false`\n *\n * Note: Useful if used with loadJSON plugin\n */\n noMetadata: customConfiguration?.noMetadata ?? COMPILER_NO_METADATA,\n\n /**\n * Indicates if the components should be saved after being transformed.\n */\n saveComponents:\n customConfiguration?.saveComponents ?? COMPILER_SAVE_COMPONENTS,\n});\n\n/**\n * Build the `dictionary` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied dictionary config.\n * @returns A fully-defaulted {@link DictionaryConfig}.\n */\nconst buildDictionaryFields = (\n customConfiguration?: Partial<DictionaryConfig>\n): DictionaryConfig => {\n const contentAutoTransformation =\n customConfiguration?.contentAutoTransformation ??\n CONTENT_AUTO_TRANSFORMATION;\n\n return {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: `true`\n *\n * - If `true`, will consider the `compiler.output` field.\n * - If `false`, will skip the fill process.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * fill: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // fill: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create custom output based on the locale\n * fill: {\n * en: ({ key }) => `/locales/en/${key}.content.json`,\n * fr: '/locales/fr/{{key}}.content.json',\n * es: false,\n * de: true,\n * },\n * }\n * ```\n *\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * Indicates if the content of the dictionary should be automatically transformed.\n *\n * Default: `false`\n */\n contentAutoTransformation:\n typeof contentAutoTransformation === 'object'\n ? {\n markdown: contentAutoTransformation.markdown ?? false,\n html: contentAutoTransformation.html ?? false,\n insertion: contentAutoTransformation.insertion ?? false,\n }\n : contentAutoTransformation,\n\n /**\n * The location of the dictionary.\n *\n * Default: `\"local\"`\n */\n location: customConfiguration?.location ?? LOCATION,\n\n /**\n * Transform the dictionary in a per-locale dictionary.\n * Each field declared in a per-locale dictionary will be transformed in a translation node.\n * If missing, the dictionary will be treated as a multilingual dictionary.\n */\n locale: customConfiguration?.locale,\n\n /**\n * The title of the dictionary.\n */\n title: customConfiguration?.title,\n\n /**\n * The description of the dictionary.\n */\n description: customConfiguration?.description,\n\n /**\n * Tags to categorize the dictionaries.\n */\n tags: customConfiguration?.tags,\n\n /**\n * The priority of the dictionary.\n */\n priority: customConfiguration?.priority,\n\n /**\n * Indicates the mode of import to use for the dictionary.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n *\n * Default: `\"static\"`\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n };\n};\n\n// ---------------------------------------------------------------------------\n// Main export\n// ---------------------------------------------------------------------------\n\n/**\n * Build the complete Intlayer configuration by merging user-supplied values\n * with defaults.\n *\n * Internally this function:\n * 1. Calls {@link buildBrowserConfiguration} to produce the browser-safe\n * subset (internationalization, routing, editor public fields, log, metadata).\n * 2. Extends the result with full server-side fields:\n * - `internationalization` — adds `requiredLocales` and `strictMode`.\n * - `editor` — adds `clientId` and `clientSecret`.\n * - `log` — adds custom log functions.\n * - `system`, `content`, `ai`, `build`, `compiler`, `dictionary`.\n *\n * @param customConfiguration - Optional user-supplied configuration object.\n * @param baseDir - Project root directory. Defaults to `process.cwd()`.\n * @param logFunctions - Optional custom logging functions.\n * @returns A fully-built {@link IntlayerConfig}.\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string,\n logFunctions?: LogFunctions\n): IntlayerConfig => {\n if (customConfiguration) {\n const result = intlayerConfigSchema.safeParse(customConfiguration);\n\n if (!result.success) {\n const logError = logFunctions?.error ?? console.error;\n\n for (const issue of result.error.issues) {\n logError(`${issue.path.join('.')}: ${issue.message}`);\n }\n }\n }\n\n // build browser-safe config (shared defaults, no Node.js deps)\n const browserConfig = buildBrowserConfiguration(customConfiguration);\n\n // extend shared fields with server-only additions\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log, logFunctions);\n\n // build server-only fields\n const systemConfig = buildSystemFields(baseDir, customConfiguration?.system);\n\n const contentConfig = buildContentFields(\n systemConfig,\n customConfiguration?.content\n );\n\n storedConfiguration = {\n // Shared browser fields\n routing: browserConfig.routing,\n // Full (extended) shared fields\n internationalization: internationalizationConfig,\n editor: editorConfig,\n log: logConfig,\n // Server-only fields\n system: systemConfig,\n content: contentConfig,\n ai: buildAiFields(customConfiguration?.ai),\n build: buildBuildFields(customConfiguration?.build),\n compiler: buildCompilerFields(customConfiguration?.compiler),\n dictionary: buildDictionaryFields(customConfiguration?.dictionary),\n plugins: customConfiguration?.plugins,\n schemas: customConfiguration?.schemas,\n } as IntlayerConfig;\n\n return storedConfiguration;\n};\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfigurationFile.mjs","names":[],"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport {\n type LoadExternalFileOptions,\n loadExternalFileSync,\n} from '../loadExternalFile/loadExternalFile';\nimport { configESMxCJSRequire } from '../utils/ESMxCJSHelpers';\n\nconst getAliases = (\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n) => {\n // Can fail if CJS hot removed from the module (e.g. in Tanstack Start + Nitro)\n try {\n return {\n ...options?.aliases,\n // Replace intlayer with @intlayer/types to avoid circular dependency intlayer -> @intlayer/config -> intlayer\n intlayer: configESMxCJSRequire.resolve('@intlayer/types'),\n };\n } catch {\n return options?.aliases;\n }\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n): CustomIntlayerConfig | undefined => {\n const fileContent = loadExternalFileSync(configFilePath, {\n ...options,\n aliases: getAliases(options),\n });\n\n return fileContent;\n};\n"],"mappings":";;;;AAOA,MAAM,cACJ,YACG;AAEH,KAAI;AACF,SAAO;GACL,GAAG,SAAS;GAEZ,UAAU,qBAAqB,QAAQ,kBAAkB;GAC1D;SACK;AACN,SAAO,SAAS;;;;;;;;;AAUpB,MAAa,yBACX,gBACA,YACqC;AAMrC,QALoB,qBAAqB,gBAAgB;EACvD,GAAG;EACH,SAAS,WAAW,QAAQ;EAC7B,
|
|
1
|
+
{"version":3,"file":"loadConfigurationFile.mjs","names":[],"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport {\n type LoadExternalFileOptions,\n loadExternalFileSync,\n} from '../loadExternalFile/loadExternalFile';\nimport { configESMxCJSRequire } from '../utils/ESMxCJSHelpers';\n\nconst getAliases = (\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n) => {\n // Can fail if CJS hot removed from the module (e.g. in Tanstack Start + Nitro)\n try {\n return {\n ...options?.aliases,\n // Replace intlayer with @intlayer/types to avoid circular dependency intlayer -> @intlayer/config -> intlayer\n intlayer: configESMxCJSRequire.resolve('@intlayer/types'),\n };\n } catch {\n return options?.aliases;\n }\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n): CustomIntlayerConfig | undefined => {\n const fileContent = loadExternalFileSync(configFilePath, {\n ...options,\n aliases: getAliases(options),\n });\n\n return fileContent;\n};\n"],"mappings":";;;;AAOA,MAAM,cACJ,YACG;AAEH,KAAI;AACF,SAAO;GACL,GAAG,SAAS;GAEZ,UAAU,qBAAqB,QAAQ,kBAAkB;GAC1D;SACK;AACN,SAAO,SAAS;;;;;;;;;AAUpB,MAAa,yBACX,gBACA,YACqC;AAMrC,QALoB,qBAAqB,gBAAgB;EACvD,GAAG;EACH,SAAS,WAAW,QAAQ;EAC7B,CAEiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleFile.mjs","names":[],"sources":["../../../src/loadExternalFile/bundleFile.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Loader,\n type Plugin,\n} from 'esbuild';\n\nexport type ESBuildPlugin = Plugin;\n\nexport const getLoader = (extension: string): Loader => {\n switch (extension) {\n case '.js':\n return 'js';\n case '.jsx':\n return 'jsx';\n case '.mjs':\n return 'js';\n case '.ts':\n return 'ts';\n case '.tsx':\n return 'tsx';\n case '.cjs':\n return 'js';\n case '.json':\n return 'json';\n case '.md':\n return 'text';\n case '.mdx':\n return 'text';\n default:\n return 'js';\n }\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node16',\n platform: 'neutral',\n write: false,\n packages: 'bundle',\n external: ['esbuild'],\n bundle: true,\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n },\n});\n\nexport const bundleFileSync = (\n code: string,\n filePath: string,\n options?: BuildOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = buildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const bundleFile = async (\n code: string,\n filePath: string,\n options?: BuildOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = await build({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":";;;;;AAaA,MAAa,aAAa,cAA8B;AACtD,SAAQ,WAAR;EACE,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,QACE,QAAO;;;AAIb,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,UAAU,CAAC,UAAU;CACrB,QAAQ;CACR,QAAQ,EACN,mBAAmB,KAAK,UAAU,cAAc,SAAS,CAAC,KAAK,EAChE;CACF;AAED,MAAa,kBACX,MACA,UACA,YACuB;AAiBvB,QAbkC,UAAU;EAC1C,OAAO;GACL,UAAU;GACV,QALW,UADG,QAAQ,
|
|
1
|
+
{"version":3,"file":"bundleFile.mjs","names":[],"sources":["../../../src/loadExternalFile/bundleFile.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Loader,\n type Plugin,\n} from 'esbuild';\n\nexport type ESBuildPlugin = Plugin;\n\nexport const getLoader = (extension: string): Loader => {\n switch (extension) {\n case '.js':\n return 'js';\n case '.jsx':\n return 'jsx';\n case '.mjs':\n return 'js';\n case '.ts':\n return 'ts';\n case '.tsx':\n return 'tsx';\n case '.cjs':\n return 'js';\n case '.json':\n return 'json';\n case '.md':\n return 'text';\n case '.mdx':\n return 'text';\n default:\n return 'js';\n }\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node16',\n platform: 'neutral',\n write: false,\n packages: 'bundle',\n external: ['esbuild'],\n bundle: true,\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n },\n});\n\nexport const bundleFileSync = (\n code: string,\n filePath: string,\n options?: BuildOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = buildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const bundleFile = async (\n code: string,\n filePath: string,\n options?: BuildOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = await build({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":";;;;;AAaA,MAAa,aAAa,cAA8B;AACtD,SAAQ,WAAR;EACE,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,QACE,QAAO;;;AAIb,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,UAAU,CAAC,UAAU;CACrB,QAAQ;CACR,QAAQ,EACN,mBAAmB,KAAK,UAAU,cAAc,SAAS,CAAC,KAAK,EAChE;CACF;AAED,MAAa,kBACX,MACA,UACA,YACuB;AAiBvB,QAbkC,UAAU;EAC1C,OAAO;GACL,UAAU;GACV,QALW,UADG,QAAQ,SACQ,CAKxB;GACN,YAAY,QAAQ,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAEsC,CAAC,cAAc,GAAG;;AAK3D,MAAa,aAAa,OACxB,MACA,UACA,YACgC;AAiBhC,SAF2B,MAXa,MAAM;EAC5C,OAAO;GACL,UAAU;GACV,QALW,UADG,QAAQ,SACQ,CAKxB;GACN,YAAY,QAAQ,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC,EAEsC,cAAc,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadExternalFile.mjs","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport {\n type TranspileOptions,\n transpileTSToCJS,\n transpileTSToCJSSync,\n} from './transpileTSToCJS';\n\n// CJS MJS cross usage\nconst parseJSON5 = JSON5.parse || (JSON5 as any).default?.parse;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: TranspileOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return parseJSON5(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return parseJSON5(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;AAiBA,MAAM,aAAa,MAAM,SAAU,MAAc,SAAS;;;;;;AAa1D,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,gBAAgB,QAAQ,SAAS,IAAI;AAE3C,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,SAGlB,QAAO,WAAW,aAAa,UAAU,QAAQ,CAAC;EAMpD,MAAM,qBAAyC,qBAFlC,aAAa,UAAU,
|
|
1
|
+
{"version":3,"file":"loadExternalFile.mjs","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport {\n type TranspileOptions,\n transpileTSToCJS,\n transpileTSToCJSSync,\n} from './transpileTSToCJS';\n\n// CJS MJS cross usage\nconst parseJSON5 = JSON5.parse || (JSON5 as any).default?.parse;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: TranspileOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return parseJSON5(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return parseJSON5(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;AAiBA,MAAM,aAAa,MAAM,SAAU,MAAc,SAAS;;;;;;AAa1D,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,gBAAgB,QAAQ,SAAS,IAAI;AAE3C,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,SAGlB,QAAO,WAAW,aAAa,UAAU,QAAQ,CAAC;EAMpD,MAAM,qBAAyC,qBAFlC,aAAa,UAAU,QAG9B,EACJ,UACA,SAAS,aACV;AAED,MAAI,CAAC,oBAAoB;AACvB,UAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAc,iBAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,UAAO,oCAAoC,WAAW;AACtD;;AAGF,SAAO;UACA,OAAO;AACd,SACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF;;;;;;;;AASL,MAAa,mBAAmB,OAC9B,UACA,YAC6B;CAC7B,MAAM,gBAAgB,QAAQ,SAAS;AAEvC,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,SAIlB,QAAO,WAAW,MADQ,SAAS,UAAU,QAAQ,CACvB;EAMhC,MAAM,qBAAyC,MAAM,iBACnD,MAHiB,SAAS,UAAU,QAAQ,EAI5C,UACA,SAAS,aACV;AAED,MAAI,CAAC,oBAAoB;AACvB,UAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAc,iBAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,UAAO,oCAAoC,aAAa,SAAS,GAAG;AACpE;;AAGF,SAAO;UACA,OAAO;AACd,MAAI,SAAS,YAAY,KACvB,QACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpileTSToCJS.mjs","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type BuildOptions, type BuildResult, build, buildSync } from 'esbuild';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { getLoader } from './bundleFile';\n\nexport type TranspileOptions = BuildOptions & {\n /**\n * Optional custom esbuild instance to use for transpilation.\n * Useful in environments (e.g. VS Code extensions) where the bundled\n * esbuild binary may not match the host platform.\n * When provided, its `buildSync`/`build` methods are used instead of\n * the ones imported from the `esbuild` package.\n */\n esbuildInstance?: typeof import('esbuild');\n};\n\nconst getTsConfigPath = (filePath: string): string | undefined => {\n const tsconfigPath = join(\n getPackageJsonPath(dirname(filePath)).baseDir,\n 'tsconfig.json'\n );\n\n // Only return the tsconfig path if it exists\n return existsSync(tsconfigPath) ? tsconfigPath : undefined;\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node20',\n platform: 'node',\n write: false,\n packages: 'external',\n bundle: true,\n tsconfig: getTsConfigPath(filePath),\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n 'import.meta.env': 'process.env',\n },\n});\n\nexport const transpileTSToCJSSync = (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n const esbuildBuildSync = esbuildInstance?.buildSync ?? buildSync;\n\n const moduleResult: BuildResult = esbuildBuildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const transpileTSToCJS = async (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n const esbuildBuild = esbuildInstance?.build ?? build;\n\n const moduleResult: BuildResult = await esbuildBuild({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":";;;;;;;;AAkBA,MAAM,mBAAmB,aAAyC;CAChE,MAAM,eAAe,KACnB,mBAAmB,QAAQ,SAAS,CAAC,CAAC,SACtC,gBACD;AAGD,QAAO,WAAW,aAAa,GAAG,eAAe;;AAGnD,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CACR,UAAU,gBAAgB,SAAS;CACnC,QAAQ;EACN,mBAAmB,KAAK,UAAU,cAAc,SAAS,CAAC,KAAK;EAC/D,mBAAmB;EACpB;CACF;AAED,MAAa,wBACX,MACA,UACA,YACuB;CAEvB,MAAM,SAAS,UADG,QAAQ,
|
|
1
|
+
{"version":3,"file":"transpileTSToCJS.mjs","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type BuildOptions, type BuildResult, build, buildSync } from 'esbuild';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { getLoader } from './bundleFile';\n\nexport type TranspileOptions = BuildOptions & {\n /**\n * Optional custom esbuild instance to use for transpilation.\n * Useful in environments (e.g. VS Code extensions) where the bundled\n * esbuild binary may not match the host platform.\n * When provided, its `buildSync`/`build` methods are used instead of\n * the ones imported from the `esbuild` package.\n */\n esbuildInstance?: typeof import('esbuild');\n};\n\nconst getTsConfigPath = (filePath: string): string | undefined => {\n const tsconfigPath = join(\n getPackageJsonPath(dirname(filePath)).baseDir,\n 'tsconfig.json'\n );\n\n // Only return the tsconfig path if it exists\n return existsSync(tsconfigPath) ? tsconfigPath : undefined;\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node20',\n platform: 'node',\n write: false,\n packages: 'external',\n bundle: true,\n tsconfig: getTsConfigPath(filePath),\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n 'import.meta.env': 'process.env',\n },\n});\n\nexport const transpileTSToCJSSync = (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n const esbuildBuildSync = esbuildInstance?.buildSync ?? buildSync;\n\n const moduleResult: BuildResult = esbuildBuildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const transpileTSToCJS = async (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n const esbuildBuild = esbuildInstance?.build ?? build;\n\n const moduleResult: BuildResult = await esbuildBuild({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":";;;;;;;;AAkBA,MAAM,mBAAmB,aAAyC;CAChE,MAAM,eAAe,KACnB,mBAAmB,QAAQ,SAAS,CAAC,CAAC,SACtC,gBACD;AAGD,QAAO,WAAW,aAAa,GAAG,eAAe;;AAGnD,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CACR,UAAU,gBAAgB,SAAS;CACnC,QAAQ;EACN,mBAAmB,KAAK,UAAU,cAAc,SAAS,CAAC,KAAK;EAC/D,mBAAmB;EACpB;CACF;AAED,MAAa,wBACX,MACA,UACA,YACuB;CAEvB,MAAM,SAAS,UADG,QAAQ,SACQ,CAAC;CAEnC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,EAAE;AAgB1D,SAfyB,iBAAiB,aAAa,WAEJ;EACjD,OAAO;GACL,UAAU;GACV;GACA,YAAY,QAAQ,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAEsC,CAAC,cAAc,GAAG;;AAK3D,MAAa,mBAAmB,OAC9B,MACA,UACA,YACgC;CAEhC,MAAM,SAAS,UADG,QAAQ,SACQ,CAAC;CAEnC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,EAAE;AAgB1D,SAF2B,OAbN,iBAAiB,SAAS,OAEM;EACnD,OAAO;GACL,UAAU;GACV;GACA,YAAY,QAAQ,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC,EAEsC,cAAc,GAAG"}
|