@intlayer/config 8.1.2 → 8.1.3
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/_virtual/_rolldown/runtime.cjs +1 -43
- package/dist/cjs/built.cjs +1 -7
- package/dist/cjs/built.cjs.map +1 -1
- package/dist/cjs/client.cjs +1 -40
- package/dist/cjs/configFile/buildConfigurationFields.cjs +1 -188
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs +1 -70
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/index.cjs +1 -10
- package/dist/cjs/configFile/loadConfigurationFile.cjs +1 -33
- package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
- package/dist/cjs/configFile/searchConfigurationFile.cjs +1 -51
- package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
- package/dist/cjs/defaultValues/build.cjs +1 -29
- package/dist/cjs/defaultValues/build.cjs.map +1 -1
- package/dist/cjs/defaultValues/compiler.cjs +1 -24
- package/dist/cjs/defaultValues/compiler.cjs.map +1 -1
- package/dist/cjs/defaultValues/content.cjs +1 -56
- package/dist/cjs/defaultValues/content.cjs.map +1 -1
- package/dist/cjs/defaultValues/dictionary.cjs +1 -26
- package/dist/cjs/defaultValues/dictionary.cjs.map +1 -1
- package/dist/cjs/defaultValues/editor.cjs +1 -41
- package/dist/cjs/defaultValues/editor.cjs.map +1 -1
- package/dist/cjs/defaultValues/index.cjs +1 -78
- package/dist/cjs/defaultValues/internationalization.cjs +1 -27
- package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
- package/dist/cjs/defaultValues/log.cjs +1 -21
- package/dist/cjs/defaultValues/log.cjs.map +1 -1
- package/dist/cjs/defaultValues/routing.cjs +1 -35
- package/dist/cjs/defaultValues/routing.cjs.map +1 -1
- package/dist/cjs/defaultValues/system.cjs +1 -47
- package/dist/cjs/defaultValues/system.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -81
- package/dist/cjs/loadEnvFile.cjs +1 -36
- package/dist/cjs/loadEnvFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleFile.cjs +1 -71
- package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleJSFile.cjs +2 -0
- package/dist/cjs/loadExternalFile/bundleJSFile.cjs.map +1 -0
- package/dist/cjs/loadExternalFile/index.cjs +1 -0
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs +1 -79
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/parseFileContent.cjs +1 -77
- package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +1 -63
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
- package/dist/cjs/logger.cjs +1 -150
- package/dist/cjs/logger.cjs.map +1 -1
- package/dist/cjs/node.cjs +1 -0
- package/dist/cjs/utils/ESMxCJSHelpers.cjs +1 -27
- package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
- package/dist/cjs/utils/alias.cjs +2 -0
- package/dist/cjs/utils/alias.cjs.map +1 -0
- package/dist/cjs/utils/cacheDisk.cjs +1 -162
- package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
- package/dist/cjs/utils/cacheMemory.cjs +1 -269
- package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
- package/dist/cjs/utils/clearModuleCache.cjs +1 -26
- package/dist/cjs/utils/clearModuleCache.cjs.map +1 -1
- package/dist/cjs/utils/compareVersions.cjs +1 -38
- package/dist/cjs/utils/compareVersions.cjs.map +1 -1
- package/dist/cjs/utils/extractErrorMessage.cjs +1 -95
- package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
- package/dist/cjs/utils/getExtension.cjs +1 -14
- package/dist/cjs/utils/getExtension.cjs.map +1 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs +1 -35
- package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -0
- package/dist/cjs/utils/logStack.cjs +1 -16
- package/dist/cjs/utils/logStack.cjs.map +1 -1
- package/dist/cjs/utils/normalizePath.cjs +1 -17
- package/dist/cjs/utils/normalizePath.cjs.map +1 -1
- package/dist/cjs/utils/retryManager.cjs +2 -0
- package/dist/cjs/utils/retryManager.cjs.map +1 -0
- package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs +1 -13
- package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs +1 -16
- package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/index.cjs +1 -10
- package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs +1 -14
- package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs +1 -19
- package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -22
- package/dist/esm/built.mjs +1 -7
- package/dist/esm/built.mjs.map +1 -1
- package/dist/esm/client.mjs +1 -11
- package/dist/esm/configFile/buildConfigurationFields.mjs +1 -186
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/getConfiguration.mjs +1 -67
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/index.mjs +1 -5
- package/dist/esm/configFile/loadConfigurationFile.mjs +1 -32
- package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
- package/dist/esm/configFile/searchConfigurationFile.mjs +1 -48
- package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
- package/dist/esm/defaultValues/build.mjs +1 -18
- package/dist/esm/defaultValues/build.mjs.map +1 -1
- package/dist/esm/defaultValues/compiler.mjs +1 -19
- package/dist/esm/defaultValues/compiler.mjs.map +1 -1
- package/dist/esm/defaultValues/content.mjs +1 -43
- package/dist/esm/defaultValues/content.mjs.map +1 -1
- package/dist/esm/defaultValues/dictionary.mjs +1 -16
- package/dist/esm/defaultValues/dictionary.mjs.map +1 -1
- package/dist/esm/defaultValues/editor.mjs +1 -26
- package/dist/esm/defaultValues/editor.mjs.map +1 -1
- package/dist/esm/defaultValues/index.mjs +1 -24
- package/dist/esm/defaultValues/internationalization.mjs +1 -17
- package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
- package/dist/esm/defaultValues/log.mjs +1 -13
- package/dist/esm/defaultValues/log.mjs.map +1 -1
- package/dist/esm/defaultValues/routing.mjs +1 -22
- package/dist/esm/defaultValues/routing.mjs.map +1 -1
- package/dist/esm/defaultValues/system.mjs +1 -30
- package/dist/esm/defaultValues/system.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -28
- package/dist/esm/loadEnvFile.mjs +1 -32
- package/dist/esm/loadEnvFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/bundleFile.mjs +1 -67
- package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/bundleJSFile.mjs +2 -0
- package/dist/esm/loadExternalFile/bundleJSFile.mjs.map +1 -0
- package/dist/esm/loadExternalFile/index.mjs +1 -0
- package/dist/esm/loadExternalFile/loadExternalFile.mjs +1 -75
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/parseFileContent.mjs +1 -73
- package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs +1 -60
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
- package/dist/esm/logger.mjs +1 -133
- package/dist/esm/logger.mjs.map +1 -1
- package/dist/esm/node.mjs +1 -0
- package/dist/esm/utils/ESMxCJSHelpers.mjs +1 -24
- package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
- package/dist/esm/utils/alias.mjs +2 -0
- package/dist/esm/utils/alias.mjs.map +1 -0
- package/dist/esm/utils/cacheDisk.mjs +1 -159
- package/dist/esm/utils/cacheDisk.mjs.map +1 -1
- package/dist/esm/utils/cacheMemory.mjs +1 -261
- package/dist/esm/utils/cacheMemory.mjs.map +1 -1
- package/dist/esm/utils/clearModuleCache.mjs +1 -25
- package/dist/esm/utils/clearModuleCache.mjs.map +1 -1
- package/dist/esm/utils/compareVersions.mjs +1 -36
- package/dist/esm/utils/compareVersions.mjs.map +1 -1
- package/dist/esm/utils/extractErrorMessage.mjs +1 -93
- package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
- package/dist/esm/utils/getExtension.mjs +1 -12
- package/dist/esm/utils/getExtension.mjs.map +1 -1
- package/dist/esm/utils/getPackageJsonPath.mjs +1 -32
- package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -0
- package/dist/esm/utils/logStack.mjs +1 -15
- package/dist/esm/utils/logStack.mjs.map +1 -1
- package/dist/esm/utils/normalizePath.mjs +1 -15
- package/dist/esm/utils/normalizePath.mjs.map +1 -1
- package/dist/esm/utils/retryManager.mjs +2 -0
- package/dist/esm/utils/retryManager.mjs.map +1 -0
- package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs +1 -11
- package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs +1 -14
- package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/index.mjs +1 -6
- package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs +1 -12
- package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs +1 -17
- package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs.map +1 -1
- package/dist/types/index.d.ts +15 -9
- package/dist/types/{bundleJSFile.d.ts → loadExternalFile/bundleJSFile.d.ts} +1 -1
- package/dist/types/loadExternalFile/bundleJSFile.d.ts.map +1 -0
- package/dist/types/loadExternalFile/index.d.ts +6 -0
- package/dist/types/loadExternalFile/loadExternalFile.d.ts +2 -3
- package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +1 -1
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts +2 -3
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -1
- package/dist/types/node.d.ts +5 -0
- package/dist/types/{alias.d.ts → utils/alias.d.ts} +1 -1
- package/dist/types/utils/alias.d.ts.map +1 -0
- package/dist/types/utils/getPackageJsonPath.d.ts +1 -2
- package/dist/types/utils/getPackageJsonPath.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +17 -0
- package/dist/types/{retryManager.d.ts → utils/retryManager.d.ts} +1 -1
- package/dist/types/utils/retryManager.d.ts.map +1 -0
- package/package.json +42 -10
- package/dist/cjs/alias.cjs +0 -30
- package/dist/cjs/alias.cjs.map +0 -1
- package/dist/cjs/bundleJSFile.cjs +0 -34
- package/dist/cjs/bundleJSFile.cjs.map +0 -1
- package/dist/cjs/retryManager.cjs +0 -46
- package/dist/cjs/retryManager.cjs.map +0 -1
- package/dist/esm/alias.mjs +0 -28
- package/dist/esm/alias.mjs.map +0 -1
- package/dist/esm/bundleJSFile.mjs +0 -32
- package/dist/esm/bundleJSFile.mjs.map +0 -1
- package/dist/esm/retryManager.mjs +0 -45
- package/dist/esm/retryManager.mjs.map +0 -1
- package/dist/types/alias.d.ts.map +0 -1
- package/dist/types/bundleJSFile.d.ts.map +0 -1
- package/dist/types/retryManager.d.ts.map +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,81 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_utils_getExtension = require('./utils/getExtension.cjs');
|
|
3
|
-
const require_utils_normalizePath = require('./utils/normalizePath.cjs');
|
|
4
|
-
const require_alias = require('./alias.cjs');
|
|
5
|
-
const require_logger = require('./logger.cjs');
|
|
6
|
-
const require_utils_cacheMemory = require('./utils/cacheMemory.cjs');
|
|
7
|
-
const require_utils_getPackageJsonPath = require('./utils/getPackageJsonPath.cjs');
|
|
8
|
-
const require_configFile_buildConfigurationFields = require('./configFile/buildConfigurationFields.cjs');
|
|
9
|
-
const require_loadEnvFile = require('./loadEnvFile.cjs');
|
|
10
|
-
const require_utils_ESMxCJSHelpers = require('./utils/ESMxCJSHelpers.cjs');
|
|
11
|
-
const require_loadExternalFile_parseFileContent = require('./loadExternalFile/parseFileContent.cjs');
|
|
12
|
-
const require_bundleJSFile = require('./bundleJSFile.cjs');
|
|
13
|
-
const require_configFile_searchConfigurationFile = require('./configFile/searchConfigurationFile.cjs');
|
|
14
|
-
const require_defaultValues_index = require('./defaultValues/index.cjs');
|
|
15
|
-
const require_loadExternalFile_bundleFile = require('./loadExternalFile/bundleFile.cjs');
|
|
16
|
-
const require_utils_extractErrorMessage = require('./utils/extractErrorMessage.cjs');
|
|
17
|
-
const require_retryManager = require('./retryManager.cjs');
|
|
18
|
-
const require_utils_cacheDisk = require('./utils/cacheDisk.cjs');
|
|
19
|
-
const require_utils_clearModuleCache = require('./utils/clearModuleCache.cjs');
|
|
20
|
-
const require_utils_compareVersions = require('./utils/compareVersions.cjs');
|
|
21
|
-
const require_utils_logStack = require('./utils/logStack.cjs');
|
|
22
|
-
const require_utils_stringFormatter_camelCaseToKebabCase = require('./utils/stringFormatter/camelCaseToKebabCase.cjs');
|
|
23
|
-
const require_utils_stringFormatter_camelCaseToSentence = require('./utils/stringFormatter/camelCaseToSentence.cjs');
|
|
24
|
-
const require_utils_stringFormatter_kebabCaseToCamelCase = require('./utils/stringFormatter/kebabCaseToCamelCase.cjs');
|
|
25
|
-
const require_utils_stringFormatter_toLowerCamelCase = require('./utils/stringFormatter/toLowerCamelCase.cjs');
|
|
26
|
-
const require_loadExternalFile_loadExternalFile = require('./loadExternalFile/loadExternalFile.cjs');
|
|
27
|
-
const require_configFile_getConfiguration = require('./configFile/getConfiguration.cjs');
|
|
28
|
-
|
|
29
|
-
exports.ANSIColors = require_logger.ANSIColors;
|
|
30
|
-
Object.defineProperty(exports, 'DefaultValues', {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return require_defaultValues_index.defaultValues_exports;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
exports.buildConfigurationFields = require_configFile_buildConfigurationFields.buildConfigurationFields;
|
|
37
|
-
exports.bundleFile = require_loadExternalFile_bundleFile.bundleFile;
|
|
38
|
-
exports.bundleFileSync = require_loadExternalFile_bundleFile.bundleFileSync;
|
|
39
|
-
exports.bundleJSFile = require_bundleJSFile.bundleJSFile;
|
|
40
|
-
exports.cacheDisk = require_utils_cacheDisk.cacheDisk;
|
|
41
|
-
exports.cacheMemory = require_utils_cacheMemory.cacheMemory;
|
|
42
|
-
exports.camelCaseToKebabCase = require_utils_stringFormatter_camelCaseToKebabCase.camelCaseToKebabCase;
|
|
43
|
-
exports.camelCaseToSentence = require_utils_stringFormatter_camelCaseToSentence.camelCaseToSentence;
|
|
44
|
-
exports.clearModuleCache = require_utils_clearModuleCache.clearModuleCache;
|
|
45
|
-
exports.clock = require_logger.clock;
|
|
46
|
-
exports.colon = require_logger.colon;
|
|
47
|
-
exports.colorize = require_logger.colorize;
|
|
48
|
-
exports.colorizeKey = require_logger.colorizeKey;
|
|
49
|
-
exports.colorizeLocales = require_logger.colorizeLocales;
|
|
50
|
-
exports.colorizeNumber = require_logger.colorizeNumber;
|
|
51
|
-
exports.colorizePath = require_logger.colorizePath;
|
|
52
|
-
exports.compareVersions = require_utils_compareVersions.compareVersions;
|
|
53
|
-
exports.configESMxCJSRequire = require_utils_ESMxCJSHelpers.configESMxCJSRequire;
|
|
54
|
-
exports.configurationFilesCandidates = require_configFile_searchConfigurationFile.configurationFilesCandidates;
|
|
55
|
-
exports.extractErrorMessage = require_utils_extractErrorMessage.extractErrorMessage;
|
|
56
|
-
exports.getAlias = require_alias.getAlias;
|
|
57
|
-
exports.getAppLogger = require_logger.getAppLogger;
|
|
58
|
-
exports.getConfiguration = require_configFile_getConfiguration.getConfiguration;
|
|
59
|
-
exports.getConfigurationAndFilePath = require_configFile_getConfiguration.getConfigurationAndFilePath;
|
|
60
|
-
exports.getEnvFilePath = require_loadEnvFile.getEnvFilePath;
|
|
61
|
-
exports.getExtension = require_utils_getExtension.getExtension;
|
|
62
|
-
exports.getPackageJsonPath = require_utils_getPackageJsonPath.getPackageJsonPath;
|
|
63
|
-
exports.getPrefix = require_logger.getPrefix;
|
|
64
|
-
exports.getProjectRequire = require_utils_ESMxCJSHelpers.getProjectRequire;
|
|
65
|
-
exports.isESModule = require_utils_ESMxCJSHelpers.isESModule;
|
|
66
|
-
exports.kebabCaseToCamelCase = require_utils_stringFormatter_kebabCaseToCamelCase.kebabCaseToCamelCase;
|
|
67
|
-
exports.loadEnvFile = require_loadEnvFile.loadEnvFile;
|
|
68
|
-
exports.loadExternalFile = require_loadExternalFile_loadExternalFile.loadExternalFile;
|
|
69
|
-
exports.loadExternalFileSync = require_loadExternalFile_loadExternalFile.loadExternalFileSync;
|
|
70
|
-
exports.logStack = require_utils_logStack.logStack;
|
|
71
|
-
exports.logger = require_logger.logger;
|
|
72
|
-
exports.normalizePath = require_utils_normalizePath.normalizePath;
|
|
73
|
-
exports.parseFileContent = require_loadExternalFile_parseFileContent.parseFileContent;
|
|
74
|
-
exports.removeColor = require_logger.removeColor;
|
|
75
|
-
exports.retryManager = require_retryManager.retryManager;
|
|
76
|
-
exports.searchConfigurationFile = require_configFile_searchConfigurationFile.searchConfigurationFile;
|
|
77
|
-
exports.setPrefix = require_logger.setPrefix;
|
|
78
|
-
exports.spinnerFrames = require_logger.spinnerFrames;
|
|
79
|
-
exports.toLowerCamelCase = require_utils_stringFormatter_toLowerCamelCase.toLowerCamelCase;
|
|
80
|
-
exports.v = require_logger.v;
|
|
81
|
-
exports.x = require_logger.x;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./logger.cjs`),t=require(`./utils/cacheMemory.cjs`),n=require(`./utils/getPackageJsonPath.cjs`),r=require(`./utils/normalizePath.cjs`),i=require(`./configFile/buildConfigurationFields.cjs`),a=require(`./loadEnvFile.cjs`),o=require(`./utils/ESMxCJSHelpers.cjs`),s=require(`./loadExternalFile/parseFileContent.cjs`),c=require(`./loadExternalFile/bundleFile.cjs`),l=require(`./loadExternalFile/transpileTSToCJS.cjs`),u=require(`./loadExternalFile/loadExternalFile.cjs`),d=require(`./configFile/searchConfigurationFile.cjs`),f=require(`./configFile/getConfiguration.cjs`),p=require(`./defaultValues/index.cjs`),m=require(`./utils/extractErrorMessage.cjs`),h=require(`./utils/logStack.cjs`),g=require(`./utils/stringFormatter/camelCaseToKebabCase.cjs`),_=require(`./utils/stringFormatter/camelCaseToSentence.cjs`),v=require(`./utils/stringFormatter/kebabCaseToCamelCase.cjs`),y=require(`./utils/stringFormatter/toLowerCamelCase.cjs`),b=require(`./loadExternalFile/bundleJSFile.cjs`),x=require(`./utils/getExtension.cjs`),S=require(`./utils/alias.cjs`),C=require(`./utils/cacheDisk.cjs`),w=require(`./utils/clearModuleCache.cjs`),T=require(`./utils/compareVersions.cjs`),E=require(`./utils/retryManager.cjs`);exports.ANSIColors=e.ANSIColors,Object.defineProperty(exports,`DefaultValues`,{enumerable:!0,get:function(){return p.defaultValues_exports}}),exports.buildConfigurationFields=i.buildConfigurationFields,exports.bundleFile=c.bundleFile,exports.bundleFileSync=c.bundleFileSync,exports.bundleJSFile=b.bundleJSFile,exports.cacheDisk=C.cacheDisk,exports.cacheMemory=t.cacheMemory,exports.camelCaseToKebabCase=g.camelCaseToKebabCase,exports.camelCaseToSentence=_.camelCaseToSentence,exports.clearAllCache=t.clearAllCache,exports.clearCache=t.clearCache,exports.clearModuleCache=w.clearModuleCache,exports.clock=e.clock,exports.colon=e.colon,exports.colorize=e.colorize,exports.colorizeKey=e.colorizeKey,exports.colorizeLocales=e.colorizeLocales,exports.colorizeNumber=e.colorizeNumber,exports.colorizePath=e.colorizePath,exports.compareVersions=T.compareVersions,exports.computeKeyId=t.computeKeyId,exports.configESMxCJSRequire=o.configESMxCJSRequire,exports.configurationFilesCandidates=d.configurationFilesCandidates,exports.extractErrorMessage=m.extractErrorMessage,exports.getAlias=S.getAlias,exports.getAppLogger=e.getAppLogger,exports.getCache=t.getCache,exports.getConfiguration=f.getConfiguration,exports.getConfigurationAndFilePath=f.getConfigurationAndFilePath,exports.getEnvFilePath=a.getEnvFilePath,exports.getExtension=x.getExtension,exports.getLoader=c.getLoader,exports.getPackageJsonPath=n.getPackageJsonPath,exports.getPrefix=e.getPrefix,exports.getProjectRequire=o.getProjectRequire,exports.getSandBoxContext=s.getSandBoxContext,exports.isESModule=o.isESModule,exports.kebabCaseToCamelCase=v.kebabCaseToCamelCase,exports.loadEnvFile=a.loadEnvFile,exports.loadExternalFile=u.loadExternalFile,exports.loadExternalFileSync=u.loadExternalFileSync,exports.logStack=h.logStack,exports.logger=e.logger,exports.normalizePath=r.normalizePath,exports.parseFileContent=s.parseFileContent,exports.removeColor=e.removeColor,exports.retryManager=E.retryManager,exports.searchConfigurationFile=d.searchConfigurationFile,exports.setCache=t.setCache,exports.setPrefix=e.setPrefix,exports.spinnerFrames=e.spinnerFrames,exports.stableStringify=t.stableStringify,exports.toLowerCamelCase=y.toLowerCamelCase,exports.transpileTSToCJS=l.transpileTSToCJS,exports.transpileTSToCJSSync=l.transpileTSToCJSSync,exports.v=e.v,exports.x=e.x;
|
package/dist/cjs/loadEnvFile.cjs
CHANGED
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
|
-
let dotenv = require("dotenv");
|
|
5
|
-
dotenv = require_runtime.__toESM(dotenv);
|
|
6
|
-
|
|
7
|
-
//#region src/loadEnvFile.ts
|
|
8
|
-
const DEFAULT_ENV = process.env.NODE_ENV ?? "development";
|
|
9
|
-
const getEnvFilePath = (env = process.env.NODE_ENV ?? "development", envFile) => {
|
|
10
|
-
return (envFile ? [envFile] : [
|
|
11
|
-
`.env.${env}.local`,
|
|
12
|
-
`.env.${env}`,
|
|
13
|
-
".env.local",
|
|
14
|
-
".env"
|
|
15
|
-
]).find(node_fs.existsSync);
|
|
16
|
-
};
|
|
17
|
-
const loadEnvFile = (options) => {
|
|
18
|
-
const env = options?.env ?? DEFAULT_ENV;
|
|
19
|
-
const envFiles = options?.envFile ? [options.envFile] : [
|
|
20
|
-
`.env.${env}.local`,
|
|
21
|
-
`.env.${env}`,
|
|
22
|
-
".env.local",
|
|
23
|
-
".env"
|
|
24
|
-
];
|
|
25
|
-
const result = {};
|
|
26
|
-
dotenv.default.config({
|
|
27
|
-
path: envFiles,
|
|
28
|
-
processEnv: result,
|
|
29
|
-
quiet: true
|
|
30
|
-
});
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
exports.getEnvFilePath = getEnvFilePath;
|
|
36
|
-
exports.loadEnvFile = loadEnvFile;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`);let t=require(`node:fs`),n=require(`dotenv`);n=e.__toESM(n);const r=process.env.NODE_ENV??`development`,i=(e=process.env.NODE_ENV??`development`,n)=>(n?[n]:[`.env.${e}.local`,`.env.${e}`,`.env.local`,`.env`]).find(t.existsSync),a=e=>{let t=e?.env??r,i=e?.envFile?[e.envFile]:[`.env.${t}.local`,`.env.${t}`,`.env.local`,`.env`],a={};return n.default.config({path:i,processEnv:a,quiet:!0}),a};exports.getEnvFilePath=i,exports.loadEnvFile=a;
|
|
37
2
|
//# sourceMappingURL=loadEnvFile.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadEnvFile.cjs","names":["existsSync"],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = options?.envFile\n ? [options.envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n const result = {};\n\n dotenv.config({\n path: envFiles,\n processEnv: result,\n quiet: true,\n });\n\n return result; // Return the parsed env object\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadEnvFile.cjs","names":["existsSync"],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = options?.envFile\n ? [options.envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n const result = {};\n\n dotenv.config({\n path: envFiles,\n processEnv: result,\n quiet: true,\n });\n\n return result; // Return the parsed env object\n};\n"],"mappings":"mLAGA,MAAM,EAAc,QAAQ,IAAI,UAAY,cAO/B,GACX,EAAc,QAAQ,IAAI,UAAY,cACtC,KAEiB,EACb,CAAC,EAAQ,CACT,CAAC,QAAQ,EAAI,QAAS,QAAQ,IAAO,aAAc,OAAO,EAE9C,KAAKA,EAAAA,WAAW,CAGrB,EAAe,GAA0C,CACpE,IAAM,EAAM,GAAS,KAAO,EAEtB,EAAW,GAAS,QACtB,CAAC,EAAQ,QAAQ,CACjB,CAAC,QAAQ,EAAI,QAAS,QAAQ,IAAO,aAAc,OAAO,CAExD,EAAS,EAAE,CAQjB,OANA,EAAA,QAAO,OAAO,CACZ,KAAM,EACN,WAAY,EACZ,MAAO,GACR,CAAC,CAEK"}
|
|
@@ -1,72 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
let esbuild = require("esbuild");
|
|
5
|
-
let node_url = require("node:url");
|
|
6
|
-
|
|
7
|
-
//#region src/loadExternalFile/bundleFile.ts
|
|
8
|
-
const getLoader = (extension) => {
|
|
9
|
-
switch (extension) {
|
|
10
|
-
case ".js": return "js";
|
|
11
|
-
case ".jsx": return "jsx";
|
|
12
|
-
case ".mjs": return "js";
|
|
13
|
-
case ".ts": return "ts";
|
|
14
|
-
case ".tsx": return "tsx";
|
|
15
|
-
case ".cjs": return "js";
|
|
16
|
-
case ".json": return "json";
|
|
17
|
-
case ".md": return "text";
|
|
18
|
-
case ".mdx": return "text";
|
|
19
|
-
default: return "js";
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const getTransformationOptions = (filePath) => ({
|
|
23
|
-
loader: {
|
|
24
|
-
".js": "js",
|
|
25
|
-
".jsx": "jsx",
|
|
26
|
-
".mjs": "js",
|
|
27
|
-
".ts": "ts",
|
|
28
|
-
".tsx": "tsx",
|
|
29
|
-
".cjs": "js",
|
|
30
|
-
".json": "json",
|
|
31
|
-
".md": "text",
|
|
32
|
-
".mdx": "text"
|
|
33
|
-
},
|
|
34
|
-
format: "cjs",
|
|
35
|
-
target: "node16",
|
|
36
|
-
platform: "neutral",
|
|
37
|
-
write: false,
|
|
38
|
-
packages: "bundle",
|
|
39
|
-
external: ["esbuild"],
|
|
40
|
-
bundle: true,
|
|
41
|
-
define: { "import.meta.url": JSON.stringify((0, node_url.pathToFileURL)(filePath).href) }
|
|
42
|
-
});
|
|
43
|
-
const bundleFileSync = (code, filePath, options) => {
|
|
44
|
-
return (0, esbuild.buildSync)({
|
|
45
|
-
stdin: {
|
|
46
|
-
contents: code,
|
|
47
|
-
loader: getLoader((0, node_path.extname)(filePath)),
|
|
48
|
-
resolveDir: (0, node_path.dirname)(filePath),
|
|
49
|
-
sourcefile: filePath
|
|
50
|
-
},
|
|
51
|
-
...getTransformationOptions(filePath),
|
|
52
|
-
...options
|
|
53
|
-
}).outputFiles?.[0].text;
|
|
54
|
-
};
|
|
55
|
-
const bundleFile = async (code, filePath, options) => {
|
|
56
|
-
return (await (0, esbuild.build)({
|
|
57
|
-
stdin: {
|
|
58
|
-
contents: code,
|
|
59
|
-
loader: getLoader((0, node_path.extname)(filePath)),
|
|
60
|
-
resolveDir: (0, node_path.dirname)(filePath),
|
|
61
|
-
sourcefile: filePath
|
|
62
|
-
},
|
|
63
|
-
...getTransformationOptions(filePath),
|
|
64
|
-
...options
|
|
65
|
-
})).outputFiles?.[0].text;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
exports.bundleFile = bundleFile;
|
|
70
|
-
exports.bundleFileSync = bundleFileSync;
|
|
71
|
-
exports.getLoader = getLoader;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`node:path`),t=require(`esbuild`),n=require(`node:url`);const r=e=>{switch(e){case`.js`:return`js`;case`.jsx`:return`jsx`;case`.mjs`:return`js`;case`.ts`:return`ts`;case`.tsx`:return`tsx`;case`.cjs`:return`js`;case`.json`:return`json`;case`.md`:return`text`;case`.mdx`:return`text`;default:return`js`}},i=e=>({loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`},format:`cjs`,target:`node16`,platform:`neutral`,write:!1,packages:`bundle`,external:[`esbuild`],bundle:!0,define:{"import.meta.url":JSON.stringify((0,n.pathToFileURL)(e).href)}}),a=(n,a,o)=>(0,t.buildSync)({stdin:{contents:n,loader:r((0,e.extname)(a)),resolveDir:(0,e.dirname)(a),sourcefile:a},...i(a),...o}).outputFiles?.[0].text,o=async(n,a,o)=>(await(0,t.build)({stdin:{contents:n,loader:r((0,e.extname)(a)),resolveDir:(0,e.dirname)(a),sourcefile:a},...i(a),...o})).outputFiles?.[0].text;exports.bundleFile=o,exports.bundleFileSync=a,exports.getLoader=r;
|
|
72
2
|
//# sourceMappingURL=bundleFile.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleFile.cjs","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":"
|
|
1
|
+
{"version":3,"file":"bundleFile.cjs","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":"sLAaA,MAAa,EAAa,GAA8B,CACtD,OAAQ,EAAR,CACE,IAAK,MACH,MAAO,KACT,IAAK,OACH,MAAO,MACT,IAAK,OACH,MAAO,KACT,IAAK,MACH,MAAO,KACT,IAAK,OACH,MAAO,MACT,IAAK,OACH,MAAO,KACT,IAAK,QACH,MAAO,OACT,IAAK,MACH,MAAO,OACT,IAAK,OACH,MAAO,OACT,QACE,MAAO,OAIP,EAA4B,IAAoC,CACpE,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACD,OAAQ,MACR,OAAQ,SACR,SAAU,UACV,MAAO,GACP,SAAU,SACV,SAAU,CAAC,UAAU,CACrB,OAAQ,GACR,OAAQ,CACN,kBAAmB,KAAK,WAAA,EAAA,EAAA,eAAwB,EAAS,CAAC,KAAK,CAChE,CACF,EAEY,GACX,EACA,EACA,KAkBA,EAAA,EAAA,WAb4C,CAC1C,MAAO,CACL,SAAU,EACV,OALW,GAAA,EAAA,EAAA,SADW,EAAS,CACA,CAM/B,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,CAEsC,cAAc,GAAG,KAK9C,EAAa,MACxB,EACA,EACA,KAKkC,MAAA,EAAA,EAAA,OAAY,CAC5C,MAAO,CACL,SAAU,EACV,OALW,GAAA,EAAA,EAAA,SADW,EAAS,CACA,CAM/B,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,EAEsC,cAAc,GAAG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`esbuild`);const t={bundle:!0,format:`cjs`,platform:`node`,target:`es2019`,sourcemap:!1,logLevel:`silent`,write:!0,packages:`external`,loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`}},n=async n=>await(0,e.build)({...t,...n});exports.bundleJSFile=n;
|
|
2
|
+
//# sourceMappingURL=bundleJSFile.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundleJSFile.cjs","names":[],"sources":["../../../src/loadExternalFile/bundleJSFile.ts"],"sourcesContent":["import { type BuildOptions, build } from 'esbuild';\n\nconst commonBuildOptions = {\n bundle: true,\n format: 'cjs',\n platform: 'node',\n target: 'es2019',\n sourcemap: false,\n logLevel: 'silent',\n write: true,\n // Bundle relative/local files, but keep bare module imports external\n packages: 'external',\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} as const;\n\nexport const bundleJSFile = async (buildOptions: BuildOptions) =>\n await build({\n ...commonBuildOptions,\n ...buildOptions,\n });\n"],"mappings":"yIAEA,MAAM,EAAqB,CACzB,OAAQ,GACR,OAAQ,MACR,SAAU,OACV,OAAQ,SACR,UAAW,GACX,SAAU,SACV,MAAO,GAEP,SAAU,WACV,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACF,CAEY,EAAe,KAAO,IACjC,MAAA,EAAA,EAAA,OAAY,CACV,GAAG,EACH,GAAG,EACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./parseFileContent.cjs`),t=require(`./bundleFile.cjs`),n=require(`./transpileTSToCJS.cjs`),r=require(`./loadExternalFile.cjs`),i=require(`./bundleJSFile.cjs`);exports.bundleFile=t.bundleFile,exports.bundleFileSync=t.bundleFileSync,exports.bundleJSFile=i.bundleJSFile,exports.getLoader=t.getLoader,exports.getSandBoxContext=e.getSandBoxContext,exports.loadExternalFile=r.loadExternalFile,exports.loadExternalFileSync=r.loadExternalFileSync,exports.parseFileContent=e.parseFileContent,exports.transpileTSToCJS=n.transpileTSToCJS,exports.transpileTSToCJSSync=n.transpileTSToCJSSync;
|
|
@@ -1,80 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_logger = require('../logger.cjs');
|
|
4
|
-
const require_loadExternalFile_parseFileContent = require('./parseFileContent.cjs');
|
|
5
|
-
const require_loadExternalFile_transpileTSToCJS = require('./transpileTSToCJS.cjs');
|
|
6
|
-
let node_path = require("node:path");
|
|
7
|
-
let node_fs = require("node:fs");
|
|
8
|
-
let node_fs_promises = require("node:fs/promises");
|
|
9
|
-
let json5 = require("json5");
|
|
10
|
-
json5 = require_runtime.__toESM(json5);
|
|
11
|
-
|
|
12
|
-
//#region src/loadExternalFile/loadExternalFile.ts
|
|
13
|
-
/**
|
|
14
|
-
* Load the content declaration from the given path
|
|
15
|
-
*
|
|
16
|
-
* Accepts JSON, JS, MJS and TS files as configuration
|
|
17
|
-
*/
|
|
18
|
-
const loadExternalFileSync = (filePath, options) => {
|
|
19
|
-
const fileExtension = (0, node_path.extname)(filePath) || ".json";
|
|
20
|
-
try {
|
|
21
|
-
if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc") return json5.default.parse((0, node_fs.readFileSync)(filePath, "utf-8"));
|
|
22
|
-
const moduleResultString = require_loadExternalFile_transpileTSToCJS.transpileTSToCJSSync((0, node_fs.readFileSync)(filePath, "utf-8"), filePath);
|
|
23
|
-
if (!moduleResultString) {
|
|
24
|
-
require_logger.logger("File could not be loaded.", { level: "error" });
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const fileContent = require_loadExternalFile_parseFileContent.parseFileContent(moduleResultString, {
|
|
28
|
-
projectRequire: options?.projectRequire,
|
|
29
|
-
envVarOptions: options?.envVarOptions,
|
|
30
|
-
additionalEnvVars: options?.additionalEnvVars,
|
|
31
|
-
mocks: options?.mocks,
|
|
32
|
-
aliases: options?.aliases
|
|
33
|
-
});
|
|
34
|
-
if (typeof fileContent === "undefined") {
|
|
35
|
-
require_logger.logger(`File could not be loaded. Path : ${filePath}`);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
return fileContent;
|
|
39
|
-
} catch (error) {
|
|
40
|
-
require_logger.logger([`Error: ${error.message} - `, JSON.stringify(error.stack, null, 2)], { level: "error" });
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Load the content declaration from the given path
|
|
45
|
-
*
|
|
46
|
-
* Accepts JSON, JS, MJS and TS files as configuration
|
|
47
|
-
*/
|
|
48
|
-
const loadExternalFile = async (filePath, options) => {
|
|
49
|
-
const fileExtension = (0, node_path.extname)(filePath);
|
|
50
|
-
try {
|
|
51
|
-
if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc") {
|
|
52
|
-
const fileContent = await (0, node_fs_promises.readFile)(filePath, "utf-8");
|
|
53
|
-
return json5.default.parse(fileContent);
|
|
54
|
-
}
|
|
55
|
-
const moduleResultString = await require_loadExternalFile_transpileTSToCJS.transpileTSToCJS(await (0, node_fs_promises.readFile)(filePath, "utf-8"), filePath, options?.buildOptions);
|
|
56
|
-
if (!moduleResultString) {
|
|
57
|
-
require_logger.logger("File could not be loaded.", { level: "error" });
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const fileContent = require_loadExternalFile_parseFileContent.parseFileContent(moduleResultString, {
|
|
61
|
-
projectRequire: options?.projectRequire,
|
|
62
|
-
envVarOptions: options?.envVarOptions,
|
|
63
|
-
additionalEnvVars: options?.additionalEnvVars,
|
|
64
|
-
mocks: options?.mocks,
|
|
65
|
-
aliases: options?.aliases
|
|
66
|
-
});
|
|
67
|
-
if (typeof fileContent === "undefined") {
|
|
68
|
-
require_logger.logger(`File could not be loaded. Path : ${require_logger.colorizePath(filePath)}`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
return fileContent;
|
|
72
|
-
} catch (error) {
|
|
73
|
-
require_logger.logger([`Error: ${error.message} - `, JSON.stringify(error.stack, null, 2)], { level: "error" });
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
exports.loadExternalFile = loadExternalFile;
|
|
79
|
-
exports.loadExternalFileSync = loadExternalFileSync;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../logger.cjs`),n=require(`./parseFileContent.cjs`),r=require(`./transpileTSToCJS.cjs`);let i=require(`node:path`),a=require(`node:fs`),o=require(`node:fs/promises`),s=require(`json5`);s=e.__toESM(s);const c=(e,o)=>{let c=(0,i.extname)(e)||`.json`;try{if(c===`.json`||c===`.json5`||c===`.jsonc`)return s.default.parse((0,a.readFileSync)(e,`utf-8`));let i=r.transpileTSToCJSSync((0,a.readFileSync)(e,`utf-8`),e);if(!i){t.logger(`File could not be loaded.`,{level:`error`});return}let l=n.parseFileContent(i,{projectRequire:o?.projectRequire,envVarOptions:o?.envVarOptions,additionalEnvVars:o?.additionalEnvVars,mocks:o?.mocks,aliases:o?.aliases});if(l===void 0){t.logger(`File could not be loaded. Path : ${e}`);return}return l}catch(e){t.logger([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}},l=async(e,a)=>{let c=(0,i.extname)(e);try{if(c===`.json`||c===`.json5`||c===`.jsonc`){let t=await(0,o.readFile)(e,`utf-8`);return s.default.parse(t)}let i=await r.transpileTSToCJS(await(0,o.readFile)(e,`utf-8`),e,a?.buildOptions);if(!i){t.logger(`File could not be loaded.`,{level:`error`});return}let l=n.parseFileContent(i,{projectRequire:a?.projectRequire,envVarOptions:a?.envVarOptions,additionalEnvVars:a?.additionalEnvVars,mocks:a?.mocks,aliases:a?.aliases});if(l===void 0){t.logger(`File could not be loaded. Path : ${t.colorizePath(e)}`);return}return l}catch(e){t.logger([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}};exports.loadExternalFile=l,exports.loadExternalFileSync=c;
|
|
80
2
|
//# sourceMappingURL=loadExternalFile.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadExternalFile.cjs","names":["JSON5","transpileTSToCJSSync","parseFileContent","transpileTSToCJS","colorizePath"],"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';\nimport type { BuildOptions
|
|
1
|
+
{"version":3,"file":"loadExternalFile.cjs","names":["JSON5","transpileTSToCJSSync","parseFileContent","transpileTSToCJS","colorizePath"],"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';\nimport type { BuildOptions } from 'esbuild';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport { transpileTSToCJS, transpileTSToCJSSync } from './transpileTSToCJS';\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: BuildOptions;\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 JSON5.parse(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 );\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 JSON5.parse(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 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"],"mappings":"2UAuBA,MAAa,GACX,EACA,IACoB,CACpB,IAAM,GAAA,EAAA,EAAA,SAAwB,EAAS,EAAI,QAE3C,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAGlB,OAAOA,EAAAA,QAAM,OAAA,EAAA,EAAA,cAAmB,EAAU,QAAQ,CAAC,CAMrD,IAAM,EAAyCC,EAAAA,sBAAAA,EAAAA,EAAAA,cAFrB,EAAU,QAAQ,CAI1C,EACD,CAED,GAAI,CAAC,EAAoB,CACvB,EAAA,OAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAcC,EAAAA,iBAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAA,OAAO,oCAAoC,IAAW,CACtD,OAGF,OAAO,QACA,EAAO,CACd,EAAA,OACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF,GASQ,EAAmB,MAC9B,EACA,IAC6B,CAC7B,IAAM,GAAA,EAAA,EAAA,SAAwB,EAAS,CAEvC,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAClB,CAEA,IAAM,EAAc,MAAA,EAAA,EAAA,UAAe,EAAU,QAAQ,CACrD,OAAOF,EAAAA,QAAM,MAAM,EAAY,CAMjC,IAAM,EAAyC,MAAMG,EAAAA,iBAFxC,MAAA,EAAA,EAAA,UAAe,EAAU,QAAQ,CAI5C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAA,OAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAcD,EAAAA,iBAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAA,OAAO,oCAAoCE,EAAAA,aAAa,EAAS,GAAG,CACpE,OAGF,OAAO,QACA,EAAO,CACd,EAAA,OACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF"}
|
|
@@ -1,78 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_loadEnvFile = require('../loadEnvFile.cjs');
|
|
4
|
-
const require_utils_ESMxCJSHelpers = require('../utils/ESMxCJSHelpers.cjs');
|
|
5
|
-
let node_vm = require("node:vm");
|
|
6
|
-
let esbuild = require("esbuild");
|
|
7
|
-
esbuild = require_runtime.__toESM(esbuild);
|
|
8
|
-
|
|
9
|
-
//#region src/loadExternalFile/parseFileContent.ts
|
|
10
|
-
const getSandBoxContext = (options) => {
|
|
11
|
-
const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } = options ?? {};
|
|
12
|
-
let additionalGlobalVar = {};
|
|
13
|
-
const baseRequire = typeof projectRequire === "function" ? projectRequire : require_utils_ESMxCJSHelpers.getProjectRequire();
|
|
14
|
-
const mockedRequire = (() => {
|
|
15
|
-
const mockTable = Object.assign({ esbuild }, mocks);
|
|
16
|
-
const aliasTable = Object.assign({}, aliases);
|
|
17
|
-
const wrappedRequire = function mockableRequire(id) {
|
|
18
|
-
const target = aliasTable?.[id] ? aliasTable[id] : id;
|
|
19
|
-
if (mockTable && Object.hasOwn(mockTable, target)) return mockTable[target];
|
|
20
|
-
if (target !== id && mockTable && Object.hasOwn(mockTable, id)) return mockTable[id];
|
|
21
|
-
return baseRequire(target);
|
|
22
|
-
};
|
|
23
|
-
wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);
|
|
24
|
-
wrappedRequire.main = baseRequire.main;
|
|
25
|
-
wrappedRequire.extensions = baseRequire.extensions;
|
|
26
|
-
wrappedRequire.cache = baseRequire.cache;
|
|
27
|
-
return wrappedRequire;
|
|
28
|
-
})();
|
|
29
|
-
try {
|
|
30
|
-
additionalGlobalVar = { React: baseRequire("react") };
|
|
31
|
-
} catch (_err) {
|
|
32
|
-
additionalGlobalVar = { React: {
|
|
33
|
-
createElement: (type, props, ...children) => ({
|
|
34
|
-
type,
|
|
35
|
-
props: {
|
|
36
|
-
...props,
|
|
37
|
-
children: children.length <= 1 ? children[0] : children
|
|
38
|
-
}
|
|
39
|
-
}),
|
|
40
|
-
Fragment: Symbol.for("react.fragment")
|
|
41
|
-
} };
|
|
42
|
-
}
|
|
43
|
-
const sandboxContext = {
|
|
44
|
-
exports: { default: {} },
|
|
45
|
-
module: { exports: {} },
|
|
46
|
-
process: {
|
|
47
|
-
...process,
|
|
48
|
-
env: {
|
|
49
|
-
...process.env,
|
|
50
|
-
...require_loadEnvFile.loadEnvFile(envVarOptions),
|
|
51
|
-
...additionalEnvVars
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
console,
|
|
55
|
-
require: mockedRequire,
|
|
56
|
-
...additionalGlobalVar
|
|
57
|
-
};
|
|
58
|
-
Object.getOwnPropertyNames(globalThis).forEach((key) => {
|
|
59
|
-
if (!(key in sandboxContext)) sandboxContext[key] = globalThis[key];
|
|
60
|
-
});
|
|
61
|
-
return sandboxContext;
|
|
62
|
-
};
|
|
63
|
-
const parseFileContent = (fileContentString, options) => {
|
|
64
|
-
const sandboxContext = getSandBoxContext(options);
|
|
65
|
-
(0, node_vm.runInNewContext)(`"use strict";\n${fileContentString}`, sandboxContext);
|
|
66
|
-
const candidates = [
|
|
67
|
-
sandboxContext.exports?.default,
|
|
68
|
-
sandboxContext.module?.exports?.defaults,
|
|
69
|
-
sandboxContext.module?.exports?.default,
|
|
70
|
-
sandboxContext.module?.exports
|
|
71
|
-
];
|
|
72
|
-
for (const candidate of candidates) if (candidate && typeof candidate === "object" && Object.keys(candidate).length > 0) return candidate;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
exports.getSandBoxContext = getSandBoxContext;
|
|
77
|
-
exports.parseFileContent = parseFileContent;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../loadEnvFile.cjs`),n=require(`../utils/ESMxCJSHelpers.cjs`);let r=require(`node:vm`),i=require(`esbuild`);i=e.__toESM(i);const a=e=>{let{envVarOptions:r,projectRequire:a,additionalEnvVars:o,mocks:s,aliases:c}=e??{},l={},u=typeof a==`function`?a:n.getProjectRequire(),d=(()=>{let e=Object.assign({esbuild:i},s),t=Object.assign({},c),n=function(n){let r=t?.[n]?t[n]:n;return e&&Object.hasOwn(e,r)?e[r]:r!==n&&e&&Object.hasOwn(e,n)?e[n]:u(r)};return n.resolve=u.resolve.bind(u),n.main=u.main,n.extensions=u.extensions,n.cache=u.cache,n})();try{l={React:u(`react`)}}catch{l={React:{createElement:(e,t,...n)=>({type:e,props:{...t,children:n.length<=1?n[0]:n}}),Fragment:Symbol.for(`react.fragment`)}}}let f={exports:{default:{}},module:{exports:{}},process:{...process,env:{...process.env,...t.loadEnvFile(r),...o}},console,require:d,...l};return Object.getOwnPropertyNames(globalThis).forEach(e=>{e in f||(f[e]=globalThis[e])}),f},o=(e,t)=>{let n=a(t);(0,r.runInNewContext)(`"use strict";\n${e}`,n);let i=[n.exports?.default,n.module?.exports?.defaults,n.module?.exports?.default,n.module?.exports];for(let e of i)if(e&&typeof e==`object`&&Object.keys(e).length>0)return e};exports.getSandBoxContext=a,exports.parseFileContent=o;
|
|
78
2
|
//# sourceMappingURL=parseFileContent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFileContent.cjs","names":["getProjectRequire","loadEnvFile"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parseFileContent.cjs","names":["getProjectRequire","loadEnvFile"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":"8PA0BA,MAAa,EAAqB,GAA6C,CAC7E,GAAM,CAAE,gBAAe,iBAAgB,oBAAmB,QAAO,WAC/D,GAAW,EAAE,CAEX,EAAsB,EAAE,CAEtB,EACJ,OAAO,GAAmB,WAAa,EAAiBA,EAAAA,mBAAmB,CAGvE,OAAuC,CAC3C,IAAM,EAAY,OAAO,OACvB,CACE,UACD,CACD,EACD,CACK,EAAa,OAAO,OAAO,EAAE,CAAE,EAAQ,CAEvC,EAAiB,SAAyB,EAAY,CAC1D,IAAM,EAAS,IAAa,GAAM,EAAW,GAAM,EAWnD,OATI,GAAa,OAAO,OAAO,EAAW,EAAO,CACxC,EAAU,GAIf,IAAW,GAAM,GAAa,OAAO,OAAO,EAAW,EAAG,CACrD,EAAU,GAGZ,EAAY,EAAO,EAS5B,MALA,GAAe,QAAU,EAAY,QAAQ,KAAK,EAAY,CAC9D,EAAe,KAAO,EAAY,KAClC,EAAe,WAAa,EAAY,WACxC,EAAe,MAAQ,EAAY,MAE5B,KACL,CAEJ,GAAI,CAEF,EAAsB,CACpB,MAAO,EAAY,QAAQ,CAC5B,MACY,CAIb,EAAsB,CACpB,MAAO,CACL,eAAgB,EAAW,EAAY,GAAG,KAAqB,CAC7D,OACA,MAAO,CACL,GAAG,EACH,SAAU,EAAS,QAAU,EAAI,EAAS,GAAK,EAChD,CACF,EACD,SAAU,OAAO,IAAI,iBAAiB,CACvC,CACF,CAGH,IAAM,EAA0B,CAC9B,QAAS,CACP,QAAS,EAAE,CACZ,CACD,OAAQ,CACN,QAAS,EAAE,CACZ,CACD,QAAS,CACP,GAAG,QACH,IAAK,CACH,GAAG,QAAQ,IACX,GAAGC,EAAAA,YAAY,EAAc,CAC7B,GAAG,EACJ,CACF,CACD,QACA,QAAS,EACT,GAAG,EACJ,CASD,OANA,OAAO,oBAAoB,WAAW,CAAC,QAAS,GAAQ,CAChD,KAAO,IACX,EAAe,GAAO,WAAW,KAEnC,CAEK,GAGI,GACX,EACA,IACkB,CAClB,IAAM,EAAiB,EAAkB,EAAQ,EAGjD,EAAA,EAAA,iBAAgB,kBAAkB,IAAqB,EAAe,CAEtE,IAAM,EAAwB,CAC5B,EAAe,SAAS,QACxB,EAAe,QAAQ,SAAS,SAChC,EAAe,QAAQ,SAAS,QAChC,EAAe,QAAQ,QACxB,CAED,IAAK,IAAM,KAAa,EACtB,GACE,GACA,OAAO,GAAc,UACrB,OAAO,KAAK,EAAoB,CAAC,OAAS,EAE1C,OAAO"}
|
|
@@ -1,64 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
|
|
4
|
-
const require_loadExternalFile_bundleFile = require('./bundleFile.cjs');
|
|
5
|
-
let node_path = require("node:path");
|
|
6
|
-
let node_fs = require("node:fs");
|
|
7
|
-
let esbuild = require("esbuild");
|
|
8
|
-
let node_url = require("node:url");
|
|
9
|
-
|
|
10
|
-
//#region src/loadExternalFile/transpileTSToCJS.ts
|
|
11
|
-
const getTsConfigPath = (filePath) => {
|
|
12
|
-
const tsconfigPath = (0, node_path.join)(require_utils_getPackageJsonPath.getPackageJsonPath((0, node_path.dirname)(filePath)).baseDir, "tsconfig.json");
|
|
13
|
-
return (0, node_fs.existsSync)(tsconfigPath) ? tsconfigPath : void 0;
|
|
14
|
-
};
|
|
15
|
-
const getTransformationOptions = (filePath) => ({
|
|
16
|
-
loader: {
|
|
17
|
-
".js": "js",
|
|
18
|
-
".jsx": "jsx",
|
|
19
|
-
".mjs": "js",
|
|
20
|
-
".ts": "ts",
|
|
21
|
-
".tsx": "tsx",
|
|
22
|
-
".cjs": "js",
|
|
23
|
-
".json": "json",
|
|
24
|
-
".md": "text",
|
|
25
|
-
".mdx": "text"
|
|
26
|
-
},
|
|
27
|
-
format: "cjs",
|
|
28
|
-
target: "node20",
|
|
29
|
-
platform: "node",
|
|
30
|
-
write: false,
|
|
31
|
-
packages: "external",
|
|
32
|
-
bundle: true,
|
|
33
|
-
tsconfig: getTsConfigPath(filePath),
|
|
34
|
-
define: { "import.meta.url": JSON.stringify((0, node_url.pathToFileURL)(filePath).href) }
|
|
35
|
-
});
|
|
36
|
-
const transpileTSToCJSSync = (code, filePath, options) => {
|
|
37
|
-
return (0, esbuild.buildSync)({
|
|
38
|
-
stdin: {
|
|
39
|
-
contents: code,
|
|
40
|
-
loader: require_loadExternalFile_bundleFile.getLoader((0, node_path.extname)(filePath)),
|
|
41
|
-
resolveDir: (0, node_path.dirname)(filePath),
|
|
42
|
-
sourcefile: filePath
|
|
43
|
-
},
|
|
44
|
-
...getTransformationOptions(filePath),
|
|
45
|
-
...options
|
|
46
|
-
}).outputFiles?.[0].text;
|
|
47
|
-
};
|
|
48
|
-
const transpileTSToCJS = async (code, filePath, options) => {
|
|
49
|
-
return (await (0, esbuild.build)({
|
|
50
|
-
stdin: {
|
|
51
|
-
contents: code,
|
|
52
|
-
loader: require_loadExternalFile_bundleFile.getLoader((0, node_path.extname)(filePath)),
|
|
53
|
-
resolveDir: (0, node_path.dirname)(filePath),
|
|
54
|
-
sourcefile: filePath
|
|
55
|
-
},
|
|
56
|
-
...getTransformationOptions(filePath),
|
|
57
|
-
...options
|
|
58
|
-
})).outputFiles?.[0].text;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
//#endregion
|
|
62
|
-
exports.transpileTSToCJS = transpileTSToCJS;
|
|
63
|
-
exports.transpileTSToCJSSync = transpileTSToCJSSync;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/getPackageJsonPath.cjs`),t=require(`./bundleFile.cjs`);let n=require(`node:path`),r=require(`node:fs`),i=require(`esbuild`),a=require(`node:url`);const o=t=>{let i=(0,n.join)(e.getPackageJsonPath((0,n.dirname)(t)).baseDir,`tsconfig.json`);return(0,r.existsSync)(i)?i:void 0},s=e=>({loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`},format:`cjs`,target:`node20`,platform:`node`,write:!1,packages:`external`,bundle:!0,tsconfig:o(e),define:{"import.meta.url":JSON.stringify((0,a.pathToFileURL)(e).href)}}),c=(e,r,a)=>(0,i.buildSync)({stdin:{contents:e,loader:t.getLoader((0,n.extname)(r)),resolveDir:(0,n.dirname)(r),sourcefile:r},...s(r),...a}).outputFiles?.[0].text,l=async(e,r,a)=>(await(0,i.build)({stdin:{contents:e,loader:t.getLoader((0,n.extname)(r)),resolveDir:(0,n.dirname)(r),sourcefile:r},...s(r),...a})).outputFiles?.[0].text;exports.transpileTSToCJS=l,exports.transpileTSToCJSSync=c;
|
|
64
2
|
//# sourceMappingURL=transpileTSToCJS.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader"],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {
|
|
1
|
+
{"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader"],"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\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 },\n});\n\nexport const transpileTSToCJSSync = (\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 transpileTSToCJS = 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":"4RAOA,MAAM,EAAmB,GAAyC,CAChE,IAAM,GAAA,EAAA,EAAA,MACJA,EAAAA,oBAAAA,EAAAA,EAAAA,SAA2B,EAAS,CAAC,CAAC,QACtC,gBACD,CAGD,OAAA,EAAA,EAAA,YAAkB,EAAa,CAAG,EAAe,IAAA,IAG7C,EAA4B,IAAoC,CACpE,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACD,OAAQ,MACR,OAAQ,SACR,SAAU,OACV,MAAO,GACP,SAAU,WACV,OAAQ,GACR,SAAU,EAAgB,EAAS,CACnC,OAAQ,CACN,kBAAmB,KAAK,WAAA,EAAA,EAAA,eAAwB,EAAS,CAAC,KAAK,CAChE,CACF,EAEY,GACX,EACA,EACA,KAkBA,EAAA,EAAA,WAb4C,CAC1C,MAAO,CACL,SAAU,EACV,OALWC,EAAAA,WAAAA,EAAAA,EAAAA,SADW,EAAS,CACA,CAM/B,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,CAEsC,cAAc,GAAG,KAK9C,EAAmB,MAC9B,EACA,EACA,KAKkC,MAAA,EAAA,EAAA,OAAY,CAC5C,MAAO,CACL,SAAU,EACV,OALWA,EAAAA,WAAAA,EAAAA,EAAAA,SADW,EAAS,CACA,CAM/B,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,EAEsC,cAAc,GAAG"}
|