@expo/require-utils 55.0.0
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/LICENSE +21 -0
- package/README.md +3 -0
- package/build/codeframe.d.ts +7 -0
- package/build/codeframe.js +87 -0
- package/build/codeframe.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +17 -0
- package/build/index.js.map +1 -0
- package/build/load.d.ts +20 -0
- package/build/load.js +203 -0
- package/build/load.js.map +1 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present 650 Industries, Inc. (aka Expo)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Diagnostic } from 'typescript';
|
|
2
|
+
export declare function formatDiagnostic(diagnostic: Diagnostic | undefined): (SyntaxError & {
|
|
3
|
+
codeFrame: string;
|
|
4
|
+
}) | null;
|
|
5
|
+
export declare function annotateError(code: string, filename: string, error: Error): (Error & {
|
|
6
|
+
codeFrame: string;
|
|
7
|
+
}) | null;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.annotateError = annotateError;
|
|
7
|
+
exports.formatDiagnostic = formatDiagnostic;
|
|
8
|
+
function _nodeUrl() {
|
|
9
|
+
const data = _interopRequireDefault(require("node:url"));
|
|
10
|
+
_nodeUrl = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
function errorToLoc(filename, error) {
|
|
17
|
+
if (error.name === 'ReferenceError' || error.name === 'SyntaxError') {
|
|
18
|
+
let stack = `${error.stack || ''}`;
|
|
19
|
+
stack = stack.slice(error.name.length + 2 /* '${name}: ' prefix */);
|
|
20
|
+
stack = stack.slice(error.message.length);
|
|
21
|
+
const trace = stack.match(/at ([^\n]+):(\d+):(\d+)/m);
|
|
22
|
+
if (_nodeUrl().default.pathToFileURL(filename).href === trace?.[1]) {
|
|
23
|
+
const line = Number(trace[2]);
|
|
24
|
+
return Number.isSafeInteger(line) ? {
|
|
25
|
+
line,
|
|
26
|
+
column: Number(trace[3]) || undefined
|
|
27
|
+
} : null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
function formatDiagnostic(diagnostic) {
|
|
33
|
+
if (!diagnostic) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const {
|
|
37
|
+
start,
|
|
38
|
+
file,
|
|
39
|
+
messageText
|
|
40
|
+
} = diagnostic;
|
|
41
|
+
if (file && messageText && start != null) {
|
|
42
|
+
const {
|
|
43
|
+
codeFrameColumns
|
|
44
|
+
} = require('@babel/code-frame');
|
|
45
|
+
const {
|
|
46
|
+
line,
|
|
47
|
+
character
|
|
48
|
+
} = file.getLineAndCharacterOfPosition(start);
|
|
49
|
+
const loc = {
|
|
50
|
+
line: line + 1,
|
|
51
|
+
column: character + 1
|
|
52
|
+
};
|
|
53
|
+
const codeFrame = codeFrameColumns(file.getText(), {
|
|
54
|
+
start: loc
|
|
55
|
+
}, {
|
|
56
|
+
highlightCode: true
|
|
57
|
+
});
|
|
58
|
+
const annotatedError = new SyntaxError(`${messageText}\n${codeFrame}`);
|
|
59
|
+
annotatedError.codeFrame = codeFrame;
|
|
60
|
+
delete annotatedError.stack;
|
|
61
|
+
return annotatedError;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
function annotateError(code, filename, error) {
|
|
66
|
+
if (typeof error !== 'object' || error == null) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const loc = errorToLoc(filename, error);
|
|
70
|
+
if (loc) {
|
|
71
|
+
const {
|
|
72
|
+
codeFrameColumns
|
|
73
|
+
} = require('@babel/code-frame');
|
|
74
|
+
const codeFrame = codeFrameColumns(code, {
|
|
75
|
+
start: loc
|
|
76
|
+
}, {
|
|
77
|
+
highlightCode: true
|
|
78
|
+
});
|
|
79
|
+
const annotatedError = error;
|
|
80
|
+
annotatedError.codeFrame = codeFrame;
|
|
81
|
+
annotatedError.message += `\n${codeFrame}`;
|
|
82
|
+
delete annotatedError.stack;
|
|
83
|
+
return annotatedError;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=codeframe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeframe.js","names":["_nodeUrl","data","_interopRequireDefault","require","e","__esModule","default","errorToLoc","filename","error","name","stack","slice","length","message","trace","match","url","pathToFileURL","href","line","Number","isSafeInteger","column","undefined","formatDiagnostic","diagnostic","start","file","messageText","codeFrameColumns","character","getLineAndCharacterOfPosition","loc","codeFrame","getText","highlightCode","annotatedError","SyntaxError","annotateError","code"],"sources":["../src/codeframe.ts"],"sourcesContent":["import url from 'node:url';\nimport type { Diagnostic } from 'typescript';\n\nfunction errorToLoc(filename: string, error: Error) {\n if (error.name === 'ReferenceError' || error.name === 'SyntaxError') {\n let stack = `${error.stack || ''}`;\n stack = stack.slice(error.name.length + 2 /* '${name}: ' prefix */);\n stack = stack.slice(error.message.length);\n const trace = stack.match(/at ([^\\n]+):(\\d+):(\\d+)/m);\n if (url.pathToFileURL(filename).href === trace?.[1]) {\n const line = Number(trace[2]);\n return Number.isSafeInteger(line) ? { line, column: Number(trace[3]) || undefined } : null;\n }\n }\n return null;\n}\n\nexport function formatDiagnostic(diagnostic: Diagnostic | undefined) {\n if (!diagnostic) {\n return null;\n }\n const { start, file, messageText } = diagnostic;\n if (file && messageText && start != null) {\n const { codeFrameColumns }: typeof import('@babel/code-frame') = require('@babel/code-frame');\n const { line, character } = file.getLineAndCharacterOfPosition(start);\n const loc = { line: line + 1, column: character + 1 };\n const codeFrame = codeFrameColumns(file.getText(), { start: loc }, { highlightCode: true });\n const annotatedError = new SyntaxError(`${messageText}\\n${codeFrame}`) as SyntaxError & {\n codeFrame: string;\n };\n annotatedError.codeFrame = codeFrame;\n delete annotatedError.stack;\n return annotatedError;\n }\n return null;\n}\n\nexport function annotateError(code: string, filename: string, error: Error) {\n if (typeof error !== 'object' || error == null) {\n return null;\n }\n const loc = errorToLoc(filename, error);\n if (loc) {\n const { codeFrameColumns }: typeof import('@babel/code-frame') = require('@babel/code-frame');\n const codeFrame = codeFrameColumns(code, { start: loc }, { highlightCode: true });\n const annotatedError = error as Error & { codeFrame: string };\n annotatedError.codeFrame = codeFrame;\n annotatedError.message += `\\n${codeFrame}`;\n delete annotatedError.stack;\n return annotatedError;\n }\n return null;\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2B,SAAAC,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG3B,SAASG,UAAUA,CAACC,QAAgB,EAAEC,KAAY,EAAE;EAClD,IAAIA,KAAK,CAACC,IAAI,KAAK,gBAAgB,IAAID,KAAK,CAACC,IAAI,KAAK,aAAa,EAAE;IACnE,IAAIC,KAAK,GAAG,GAAGF,KAAK,CAACE,KAAK,IAAI,EAAE,EAAE;IAClCA,KAAK,GAAGA,KAAK,CAACC,KAAK,CAACH,KAAK,CAACC,IAAI,CAACG,MAAM,GAAG,CAAC,CAAC,wBAAwB,CAAC;IACnEF,KAAK,GAAGA,KAAK,CAACC,KAAK,CAACH,KAAK,CAACK,OAAO,CAACD,MAAM,CAAC;IACzC,MAAME,KAAK,GAAGJ,KAAK,CAACK,KAAK,CAAC,0BAA0B,CAAC;IACrD,IAAIC,kBAAG,CAACC,aAAa,CAACV,QAAQ,CAAC,CAACW,IAAI,KAAKJ,KAAK,GAAG,CAAC,CAAC,EAAE;MACnD,MAAMK,IAAI,GAAGC,MAAM,CAACN,KAAK,CAAC,CAAC,CAAC,CAAC;MAC7B,OAAOM,MAAM,CAACC,aAAa,CAACF,IAAI,CAAC,GAAG;QAAEA,IAAI;QAAEG,MAAM,EAAEF,MAAM,CAACN,KAAK,CAAC,CAAC,CAAC,CAAC,IAAIS;MAAU,CAAC,GAAG,IAAI;IAC5F;EACF;EACA,OAAO,IAAI;AACb;AAEO,SAASC,gBAAgBA,CAAC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,CAAC,EAAE;MAAEG,aAAa,EAAE;IAAK,CAAC,CAAC;IACjF,MAAMC,cAAc,GAAG5B,KAAsC;IAC7D4B,cAAc,CAACH,SAAS,GAAGA,SAAS;IACpCG,cAAc,CAACvB,OAAO,IAAI,KAAKoB,SAAS,EAAE;IAC1C,OAAOG,cAAc,CAAC1B,KAAK;IAC3B,OAAO0B,cAAc;EACvB;EACA,OAAO,IAAI;AACb","ignoreList":[]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './load';
|
package/build/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _load = require("./load");
|
|
7
|
+
Object.keys(_load).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _load[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _load[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_load","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../src/index.ts"],"sourcesContent":["export * from './load';\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/build/load.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare module 'node:module' {
|
|
2
|
+
function _nodeModulePaths(base: string): readonly string[];
|
|
3
|
+
}
|
|
4
|
+
declare global {
|
|
5
|
+
namespace NodeJS {
|
|
6
|
+
interface Module {
|
|
7
|
+
_compile(code: string, filename: string, format?: 'module' | 'commonjs' | 'commonjs-typescript' | 'module-typescript' | 'typescript'): unknown;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export interface ModuleOptions {
|
|
12
|
+
paths?: string[];
|
|
13
|
+
}
|
|
14
|
+
declare function evalModule(code: string, filename: string, opts?: ModuleOptions): any;
|
|
15
|
+
declare function loadModule(filename: string): Promise<any>;
|
|
16
|
+
/** Require module or evaluate with TypeScript
|
|
17
|
+
* NOTE: Requiring ESM has been added in all LTS versions (Node 20.19+, 22.12+, 24).
|
|
18
|
+
* This already forms the minimum required Node version as of Expo SDK 54 */
|
|
19
|
+
declare function loadModuleSync(filename: string): any;
|
|
20
|
+
export { evalModule, loadModule, loadModuleSync };
|
package/build/load.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.evalModule = evalModule;
|
|
7
|
+
exports.loadModule = loadModule;
|
|
8
|
+
exports.loadModuleSync = loadModuleSync;
|
|
9
|
+
function _nodeFs() {
|
|
10
|
+
const data = _interopRequireDefault(require("node:fs"));
|
|
11
|
+
_nodeFs = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function nodeModule() {
|
|
17
|
+
const data = _interopRequireWildcard(require("node:module"));
|
|
18
|
+
nodeModule = function () {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
function _nodePath() {
|
|
24
|
+
const data = _interopRequireDefault(require("node:path"));
|
|
25
|
+
_nodePath = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
function _nodeUrl() {
|
|
31
|
+
const data = _interopRequireDefault(require("node:url"));
|
|
32
|
+
_nodeUrl = function () {
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
function _codeframe() {
|
|
38
|
+
const data = require("./codeframe");
|
|
39
|
+
_codeframe = function () {
|
|
40
|
+
return data;
|
|
41
|
+
};
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
45
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
47
|
+
let _ts;
|
|
48
|
+
function loadTypescript() {
|
|
49
|
+
if (_ts === undefined) {
|
|
50
|
+
try {
|
|
51
|
+
_ts = require('typescript');
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error.code !== 'MODULE_NOT_FOUND') {
|
|
54
|
+
throw error;
|
|
55
|
+
} else {
|
|
56
|
+
_ts = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return _ts;
|
|
61
|
+
}
|
|
62
|
+
const parent = module;
|
|
63
|
+
const tsExtensionMapping = {
|
|
64
|
+
'.ts': '.js',
|
|
65
|
+
'.cts': '.cjs',
|
|
66
|
+
'.mts': '.mjs'
|
|
67
|
+
};
|
|
68
|
+
function toFormat(filename) {
|
|
69
|
+
if (filename.endsWith('.cjs')) {
|
|
70
|
+
return 'commonjs';
|
|
71
|
+
} else if (filename.endsWith('.mjs')) {
|
|
72
|
+
return 'module';
|
|
73
|
+
} else if (filename.endsWith('.js')) {
|
|
74
|
+
return undefined;
|
|
75
|
+
} else if (filename.endsWith('.mts')) {
|
|
76
|
+
return 'module-typescript';
|
|
77
|
+
} else if (filename.endsWith('.cts')) {
|
|
78
|
+
return 'commonjs-typescript';
|
|
79
|
+
} else if (filename.endsWith('.ts')) {
|
|
80
|
+
return 'typescript';
|
|
81
|
+
} else {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function isTypescriptFilename(filename) {
|
|
86
|
+
switch (toFormat(filename)) {
|
|
87
|
+
case 'module-typescript':
|
|
88
|
+
case 'commonjs-typescript':
|
|
89
|
+
case 'typescript':
|
|
90
|
+
return true;
|
|
91
|
+
default:
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function compileModule(code, filename, opts) {
|
|
96
|
+
const format = toFormat(filename);
|
|
97
|
+
const prependPaths = opts.paths ?? [];
|
|
98
|
+
const nodeModulePaths = nodeModule()._nodeModulePaths(_nodePath().default.dirname(filename));
|
|
99
|
+
const paths = [...prependPaths, ...nodeModulePaths];
|
|
100
|
+
try {
|
|
101
|
+
const mod = Object.assign(new (nodeModule().Module)(filename, parent), {
|
|
102
|
+
filename,
|
|
103
|
+
paths
|
|
104
|
+
});
|
|
105
|
+
mod._compile(code, filename, format);
|
|
106
|
+
require.cache[filename] = mod;
|
|
107
|
+
parent?.children?.splice(parent.children.indexOf(mod), 1);
|
|
108
|
+
return mod.exports;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
delete require.cache[filename];
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const hasStripTypeScriptTypes = typeof nodeModule().stripTypeScriptTypes === 'function';
|
|
115
|
+
function evalModule(code, filename, opts = {}) {
|
|
116
|
+
let inputCode = code;
|
|
117
|
+
let inputFilename = filename;
|
|
118
|
+
let diagnostic;
|
|
119
|
+
if (filename.endsWith('.ts') || filename.endsWith('.cts') || filename.endsWith('.mts')) {
|
|
120
|
+
const ext = _nodePath().default.extname(filename);
|
|
121
|
+
const ts = loadTypescript();
|
|
122
|
+
if (ts) {
|
|
123
|
+
const output = ts.transpileModule(code, {
|
|
124
|
+
fileName: filename,
|
|
125
|
+
reportDiagnostics: true,
|
|
126
|
+
compilerOptions: {
|
|
127
|
+
module: ext === '.cts' ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext,
|
|
128
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
newLine: ts.NewLineKind.LineFeed,
|
|
131
|
+
inlineSourceMap: true
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
inputCode = output?.outputText || inputCode;
|
|
135
|
+
if (output?.diagnostics?.length) {
|
|
136
|
+
diagnostic = output.diagnostics[0];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (hasStripTypeScriptTypes && inputCode === code) {
|
|
140
|
+
// This may throw its own error, but this contains a code-frame already
|
|
141
|
+
inputCode = nodeModule().stripTypeScriptTypes(code, {
|
|
142
|
+
mode: 'transform',
|
|
143
|
+
sourceMap: true
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (inputCode !== code) {
|
|
147
|
+
const inputExt = tsExtensionMapping[ext] ?? ext;
|
|
148
|
+
if (inputExt !== ext) {
|
|
149
|
+
inputFilename = _nodePath().default.join(_nodePath().default.dirname(filename), _nodePath().default.basename(filename, ext) + inputExt);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
const mod = compileModule(inputCode, inputFilename, opts);
|
|
155
|
+
if (inputFilename !== filename) {
|
|
156
|
+
require.cache[filename] = mod;
|
|
157
|
+
}
|
|
158
|
+
return mod;
|
|
159
|
+
} catch (error) {
|
|
160
|
+
// If we have a diagnostic from TypeScript, we issue its error with a codeframe first,
|
|
161
|
+
// since it's likely more useful than the eval error
|
|
162
|
+
throw (0, _codeframe().formatDiagnostic)(diagnostic) ?? (0, _codeframe().annotateError)(code, filename, error) ?? error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function requireOrImport(filename) {
|
|
166
|
+
try {
|
|
167
|
+
return require(filename);
|
|
168
|
+
} catch {
|
|
169
|
+
return await Promise.resolve(`${_nodePath().default.isAbsolute(filename) ? _nodeUrl().default.pathToFileURL(filename).toString() : filename}`).then(s => _interopRequireWildcard(require(s)));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function loadModule(filename) {
|
|
173
|
+
try {
|
|
174
|
+
return await requireOrImport(filename);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
if (error.code === 'ERR_UNKNOWN_FILE_EXTENSION' || error.code === 'MODULE_NOT_FOUND') {
|
|
177
|
+
return loadModuleSync(filename);
|
|
178
|
+
} else {
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Require module or evaluate with TypeScript
|
|
185
|
+
* NOTE: Requiring ESM has been added in all LTS versions (Node 20.19+, 22.12+, 24).
|
|
186
|
+
* This already forms the minimum required Node version as of Expo SDK 54 */
|
|
187
|
+
function loadModuleSync(filename) {
|
|
188
|
+
try {
|
|
189
|
+
if (!isTypescriptFilename(filename)) {
|
|
190
|
+
return require(filename);
|
|
191
|
+
}
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (error.code === 'MODULE_NOT_FOUND') {
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
// We fallback to always evaluating the entrypoint module
|
|
197
|
+
// This is out of safety, since we're not trusting the requiring ESM feature
|
|
198
|
+
// and evaluating the module manually bypasses the error when it's flagged off
|
|
199
|
+
}
|
|
200
|
+
const code = _nodeFs().default.readFileSync(filename, 'utf8');
|
|
201
|
+
return evalModule(code, filename);
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","names":["_nodeFs","data","_interopRequireDefault","require","nodeModule","_interopRequireWildcard","_nodePath","_nodeUrl","_codeframe","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_ts","loadTypescript","undefined","error","code","parent","module","tsExtensionMapping","toFormat","filename","endsWith","isTypescriptFilename","compileModule","opts","format","prependPaths","paths","nodeModulePaths","_nodeModulePaths","path","dirname","mod","assign","Module","_compile","cache","children","splice","indexOf","exports","hasStripTypeScriptTypes","stripTypeScriptTypes","evalModule","inputCode","inputFilename","diagnostic","ext","extname","ts","output","transpileModule","fileName","reportDiagnostics","compilerOptions","ModuleKind","CommonJS","ESNext","moduleResolution","ModuleResolutionKind","Bundler","target","ScriptTarget","newLine","NewLineKind","LineFeed","inlineSourceMap","outputText","diagnostics","length","mode","sourceMap","inputExt","join","basename","formatDiagnostic","annotateError","requireOrImport","Promise","resolve","isAbsolute","url","pathToFileURL","toString","then","s","loadModule","loadModuleSync","fs","readFileSync"],"sources":["../src/load.ts"],"sourcesContent":["import fs from 'node:fs';\nimport * as nodeModule from 'node:module';\nimport path from 'node:path';\nimport url from 'node:url';\nimport type * as ts from 'typescript';\n\nimport { annotateError, formatDiagnostic } from './codeframe';\n\ndeclare module 'node:module' {\n export function _nodeModulePaths(base: string): readonly string[];\n}\n\ndeclare global {\n namespace NodeJS {\n export interface Module {\n _compile(\n code: string,\n filename: string,\n format?: 'module' | 'commonjs' | 'commonjs-typescript' | 'module-typescript' | 'typescript'\n ): unknown;\n }\n }\n}\n\nlet _ts: typeof import('typescript') | null | undefined;\nfunction loadTypescript() {\n if (_ts === undefined) {\n try {\n _ts = require('typescript');\n } catch (error: any) {\n if (error.code !== 'MODULE_NOT_FOUND') {\n throw error;\n } else {\n _ts = null;\n }\n }\n }\n return _ts;\n}\n\nconst parent = module;\n\nconst tsExtensionMapping: Record<string, string | undefined> = {\n '.ts': '.js',\n '.cts': '.cjs',\n '.mts': '.mjs',\n};\n\nfunction toFormat(filename: string) {\n if (filename.endsWith('.cjs')) {\n return 'commonjs';\n } else if (filename.endsWith('.mjs')) {\n return 'module';\n } else if (filename.endsWith('.js')) {\n return undefined;\n } else if (filename.endsWith('.mts')) {\n return 'module-typescript';\n } else if (filename.endsWith('.cts')) {\n return 'commonjs-typescript';\n } else if (filename.endsWith('.ts')) {\n return 'typescript';\n } else {\n return undefined;\n }\n}\n\nfunction isTypescriptFilename(filename: string) {\n switch (toFormat(filename)) {\n case 'module-typescript':\n case 'commonjs-typescript':\n case 'typescript':\n return true;\n default:\n return false;\n }\n}\n\nexport interface ModuleOptions {\n paths?: string[];\n}\n\nfunction compileModule<T = any>(code: string, filename: string, opts: ModuleOptions): T {\n const format = toFormat(filename);\n const prependPaths = opts.paths ?? [];\n const nodeModulePaths = nodeModule._nodeModulePaths(path.dirname(filename));\n const paths = [...prependPaths, ...nodeModulePaths];\n try {\n const mod = Object.assign(new nodeModule.Module(filename, parent), { filename, paths });\n mod._compile(code, filename, format);\n require.cache[filename] = mod;\n parent?.children?.splice(parent.children.indexOf(mod), 1);\n return mod.exports;\n } catch (error: any) {\n delete require.cache[filename];\n throw error;\n }\n}\n\nconst hasStripTypeScriptTypes = typeof nodeModule.stripTypeScriptTypes === 'function';\n\nfunction evalModule(code: string, filename: string, opts: ModuleOptions = {}) {\n let inputCode = code;\n let inputFilename = filename;\n let diagnostic: ts.Diagnostic | undefined;\n if (filename.endsWith('.ts') || filename.endsWith('.cts') || filename.endsWith('.mts')) {\n const ext = path.extname(filename);\n const ts = loadTypescript();\n\n if (ts) {\n const output = ts.transpileModule(code, {\n fileName: filename,\n reportDiagnostics: true,\n compilerOptions: {\n module: ext === '.cts' ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n target: ts.ScriptTarget.ESNext,\n newLine: ts.NewLineKind.LineFeed,\n inlineSourceMap: true,\n },\n });\n inputCode = output?.outputText || inputCode;\n if (output?.diagnostics?.length) {\n diagnostic = output.diagnostics[0];\n }\n }\n\n if (hasStripTypeScriptTypes && inputCode === code) {\n // This may throw its own error, but this contains a code-frame already\n inputCode = nodeModule.stripTypeScriptTypes(code, {\n mode: 'transform',\n sourceMap: true,\n });\n }\n\n if (inputCode !== code) {\n const inputExt = tsExtensionMapping[ext] ?? ext;\n if (inputExt !== ext) {\n inputFilename = path.join(path.dirname(filename), path.basename(filename, ext) + inputExt);\n }\n }\n }\n\n try {\n const mod = compileModule(inputCode, inputFilename, opts);\n if (inputFilename !== filename) {\n require.cache[filename] = mod;\n }\n return mod;\n } catch (error: any) {\n // If we have a diagnostic from TypeScript, we issue its error with a codeframe first,\n // since it's likely more useful than the eval error\n throw formatDiagnostic(diagnostic) ?? annotateError(code, filename, error) ?? error;\n }\n}\n\nasync function requireOrImport(filename: string) {\n try {\n return require(filename);\n } catch {\n return await import(\n path.isAbsolute(filename) ? url.pathToFileURL(filename).toString() : filename\n );\n }\n}\n\nasync function loadModule(filename: string) {\n try {\n return await requireOrImport(filename);\n } catch (error: any) {\n if (error.code === 'ERR_UNKNOWN_FILE_EXTENSION' || error.code === 'MODULE_NOT_FOUND') {\n return loadModuleSync(filename);\n } else {\n throw error;\n }\n }\n}\n\n/** Require module or evaluate with TypeScript\n * NOTE: Requiring ESM has been added in all LTS versions (Node 20.19+, 22.12+, 24).\n * This already forms the minimum required Node version as of Expo SDK 54 */\nfunction loadModuleSync(filename: string) {\n try {\n if (!isTypescriptFilename(filename)) {\n return require(filename);\n }\n } catch (error: any) {\n if (error.code === 'MODULE_NOT_FOUND') {\n throw error;\n }\n // We fallback to always evaluating the entrypoint module\n // This is out of safety, since we're not trusting the requiring ESM feature\n // and evaluating the module manually bypasses the error when it's flagged off\n }\n const code = fs.readFileSync(filename, 'utf8');\n return evalModule(code, filename);\n}\n\nexport { evalModule, loadModule, loadModuleSync };\n"],"mappings":";;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAF,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,SAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,UAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8D,SAAAC,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,C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IACF,IAAI,CAACE,oBAAoB,CAACF,QAAQ,CAAC,EAAE;MACnC,OAAOnC,OAAO,CAACmC,QAAQ,CAAC;IAC1B;EACF,CAAC,CAAC,OAAON,KAAU,EAAE;IACnB,IAAIA,KAAK,CAACC,IAAI,KAAK,kBAAkB,EAAE;MACrC,MAAMD,KAAK;IACb;IACA;IACA;IACA;EACF;EACA,MAAMC,IAAI,GAAGyE,iBAAE,CAACC,YAAY,CAACrE,QAAQ,EAAE,MAAM,CAAC;EAC9C,OAAOuB,UAAU,CAAC5B,IAAI,EAAEK,QAAQ,CAAC;AACnC","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@expo/require-utils",
|
|
3
|
+
"version": "55.0.0",
|
|
4
|
+
"description": "Reusable require and Node resolution utilities library for Expo",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./build/index.js",
|
|
7
|
+
"types": "./build/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"build"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc --emitDeclarationOnly && babel src --out-dir build --extensions \".ts\" --source-maps --ignore \"src/**/__mocks__/*\",\"src/**/__tests__/*\"",
|
|
13
|
+
"clean": "expo-module clean",
|
|
14
|
+
"lint": "expo-module lint",
|
|
15
|
+
"generate": "node ./scripts/generate.js",
|
|
16
|
+
"prepare": "yarn run clean && yarn run build",
|
|
17
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
18
|
+
"test": "expo-module test",
|
|
19
|
+
"typecheck": "expo-module typecheck"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/expo/expo/tree/main/packages/@expo/require-utils#readme",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/expo/expo.git",
|
|
25
|
+
"directory": "packages/@expo/require-utils"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/expo/expo/issues"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"typescript": "^5.0.0 || ^5.0.0-0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"typescript": {
|
|
35
|
+
"optional": true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@babel/code-frame": "^7.20.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^22.14.0",
|
|
43
|
+
"expo-module-scripts": "^55.0.2",
|
|
44
|
+
"typescript": "^5.9.2"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "aeb65063e482533ed1119f736555bcca5af2af94"
|
|
50
|
+
}
|