@expo/metro-config 0.7.0 → 0.8.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/build/ExpoMetroConfig.d.ts +16 -8
- package/build/ExpoMetroConfig.js +157 -103
- package/build/ExpoMetroConfig.js.map +1 -1
- package/build/customizeFrame.d.ts +10 -0
- package/build/customizeFrame.js +85 -0
- package/build/customizeFrame.js.map +1 -0
- package/build/env.d.ts +16 -0
- package/build/env.js +47 -0
- package/build/env.js.map +1 -0
- package/build/getModulesPaths.d.ts +1 -0
- package/build/getModulesPaths.js +12 -0
- package/build/getModulesPaths.js.map +1 -1
- package/build/getWatchFolders.js.map +1 -1
- package/build/rewriteRequestUrl.d.ts +1 -0
- package/build/rewriteRequestUrl.js +88 -0
- package/build/rewriteRequestUrl.js.map +1 -0
- package/build/serializer/environmentVariableSerializerPlugin.d.ts +11 -0
- package/build/serializer/environmentVariableSerializerPlugin.js +116 -0
- package/build/serializer/environmentVariableSerializerPlugin.js.map +1 -0
- package/build/serializer/getCssDeps.d.ts +31 -0
- package/build/serializer/getCssDeps.js +107 -0
- package/build/serializer/getCssDeps.js.map +1 -0
- package/build/serializer/serializerAssets.d.ts +7 -0
- package/build/serializer/serializerAssets.js +2 -0
- package/build/serializer/serializerAssets.js.map +1 -0
- package/build/serializer/withExpoSerializers.d.ts +15 -0
- package/build/serializer/withExpoSerializers.js +135 -0
- package/build/serializer/withExpoSerializers.js.map +1 -0
- package/build/transform-worker/css-modules.d.ts +20 -0
- package/build/transform-worker/css-modules.js +93 -0
- package/build/transform-worker/css-modules.js.map +1 -0
- package/build/transform-worker/css.d.ts +7 -0
- package/build/transform-worker/css.js +49 -0
- package/build/transform-worker/css.js.map +1 -0
- package/build/transform-worker/postcss.d.ts +17 -0
- package/build/transform-worker/postcss.js +253 -0
- package/build/transform-worker/postcss.js.map +1 -0
- package/build/transform-worker/sass.d.ts +9 -0
- package/build/transform-worker/sass.js +49 -0
- package/build/transform-worker/sass.js.map +1 -0
- package/build/transform-worker/transform-worker.d.ts +3 -0
- package/build/transform-worker/transform-worker.js +180 -0
- package/build/transform-worker/transform-worker.js.map +1 -0
- package/build/transform-worker/utils/require.d.ts +2 -0
- package/build/transform-worker/utils/require.js +38 -0
- package/build/transform-worker/utils/require.js.map +1 -0
- package/build/transformer/createExoticTransformer.js.map +1 -1
- package/build/transformer/createMatcher.js +1 -1
- package/build/transformer/createMatcher.js.map +1 -1
- package/build/transformer/createMultiRuleTransformer.js +2 -2
- package/build/transformer/createMultiRuleTransformer.js.map +1 -1
- package/build/transformer/generateFunctionMap.d.ts +3 -1
- package/build/transformer/generateFunctionMap.js +6 -6
- package/build/transformer/generateFunctionMap.js.map +1 -1
- package/build/transformer/getBabelConfig.js.map +1 -1
- package/build/transformer/getCacheKey.js.map +1 -1
- package/build/transformer/index.js.map +1 -1
- package/build/transformer/metro-expo-babel-transformer.js.map +1 -1
- package/build/transformer/metro-expo-exotic-babel-transformer.js.map +1 -1
- package/build/traveling/metro-config.d.ts +1 -0
- package/build/traveling/metro-config.js +25 -0
- package/build/traveling/metro-config.js.map +1 -0
- package/build/utils/hash.d.ts +1 -0
- package/build/utils/hash.js +18 -0
- package/build/utils/hash.js.map +1 -0
- package/package.json +9 -7
- package/build/importMetroFromProject.d.ts +0 -4
- package/build/importMetroFromProject.js +0 -40
- package/build/importMetroFromProject.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="source-map-js" />
|
|
2
|
+
export declare function matchSass(filename: string): import('sass').Syntax | null;
|
|
3
|
+
export declare function compileSass(projectRoot: string, { filename, src }: {
|
|
4
|
+
filename: string;
|
|
5
|
+
src: string;
|
|
6
|
+
}, options?: Partial<import('sass').StringOptions<'sync'>>): {
|
|
7
|
+
src: string;
|
|
8
|
+
map: import("source-map-js").RawSourceMap | undefined;
|
|
9
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compileSass = compileSass;
|
|
7
|
+
exports.matchSass = matchSass;
|
|
8
|
+
function _resolveFrom() {
|
|
9
|
+
const data = _interopRequireDefault(require("resolve-from"));
|
|
10
|
+
_resolveFrom = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
let sassInstance = null;
|
|
17
|
+
function getSassInstance(projectRoot) {
|
|
18
|
+
if (!sassInstance) {
|
|
19
|
+
const sassPath = _resolveFrom().default.silent(projectRoot, 'sass');
|
|
20
|
+
if (!sassPath) {
|
|
21
|
+
throw new Error(`Cannot parse Sass files without the module 'sass' installed. Run 'yarn add sass' and try again.`);
|
|
22
|
+
}
|
|
23
|
+
sassInstance = require(sassPath);
|
|
24
|
+
}
|
|
25
|
+
return sassInstance;
|
|
26
|
+
}
|
|
27
|
+
function matchSass(filename) {
|
|
28
|
+
if (filename.endsWith('.sass')) {
|
|
29
|
+
return 'indented';
|
|
30
|
+
} else if (filename.endsWith('.scss')) {
|
|
31
|
+
return 'scss';
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
function compileSass(projectRoot, {
|
|
36
|
+
filename,
|
|
37
|
+
src
|
|
38
|
+
},
|
|
39
|
+
// TODO: Expose to users somehow...
|
|
40
|
+
options) {
|
|
41
|
+
const sass = getSassInstance(projectRoot);
|
|
42
|
+
const result = sass.compileString(src, options);
|
|
43
|
+
return {
|
|
44
|
+
src: result.css,
|
|
45
|
+
// TODO: Should we use this? Leaning towards no since the CSS will be parsed again by the CSS loader.
|
|
46
|
+
map: result.sourceMap
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=sass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sass.js","names":["_resolveFrom","data","_interopRequireDefault","require","obj","__esModule","default","sassInstance","getSassInstance","projectRoot","sassPath","resolveFrom","silent","Error","matchSass","filename","endsWith","compileSass","src","options","sass","result","compileString","css","map","sourceMap"],"sources":["../../src/transform-worker/sass.ts"],"sourcesContent":["import resolveFrom from 'resolve-from';\n\nlet sassInstance: typeof import('sass') | null = null;\n\nfunction getSassInstance(projectRoot: string) {\n if (!sassInstance) {\n const sassPath = resolveFrom.silent(projectRoot, 'sass');\n\n if (!sassPath) {\n throw new Error(\n `Cannot parse Sass files without the module 'sass' installed. Run 'yarn add sass' and try again.`\n );\n }\n\n sassInstance = require(sassPath) as typeof import('sass');\n }\n\n return sassInstance;\n}\n\nexport function matchSass(filename: string): import('sass').Syntax | null {\n if (filename.endsWith('.sass')) {\n return 'indented';\n } else if (filename.endsWith('.scss')) {\n return 'scss';\n }\n return null;\n}\n\nexport function compileSass(\n projectRoot: string,\n { filename, src }: { filename: string; src: string },\n // TODO: Expose to users somehow...\n options?: Partial<import('sass').StringOptions<'sync'>>\n) {\n const sass = getSassInstance(projectRoot);\n const result = sass.compileString(src, options);\n return {\n src: result.css,\n // TODO: Should we use this? Leaning towards no since the CSS will be parsed again by the CSS loader.\n map: result.sourceMap,\n };\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuC,SAAAC,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEvC,IAAIG,YAA0C,GAAG,IAAI;AAErD,SAASC,eAAeA,CAACC,WAAmB,EAAE;EAC5C,IAAI,CAACF,YAAY,EAAE;IACjB,MAAMG,QAAQ,GAAGC,sBAAW,CAACC,MAAM,CAACH,WAAW,EAAE,MAAM,CAAC;IAExD,IAAI,CAACC,QAAQ,EAAE;MACb,MAAM,IAAIG,KAAK,CACZ,iGAAgG,CAClG;IACH;IAEAN,YAAY,GAAGJ,OAAO,CAACO,QAAQ,CAA0B;EAC3D;EAEA,OAAOH,YAAY;AACrB;AAEO,SAASO,SAASA,CAACC,QAAgB,EAAgC;EACxE,IAAIA,QAAQ,CAACC,QAAQ,CAAC,OAAO,CAAC,EAAE;IAC9B,OAAO,UAAU;EACnB,CAAC,MAAM,IAAID,QAAQ,CAACC,QAAQ,CAAC,OAAO,CAAC,EAAE;IACrC,OAAO,MAAM;EACf;EACA,OAAO,IAAI;AACb;AAEO,SAASC,WAAWA,CACzBR,WAAmB,EACnB;EAAEM,QAAQ;EAAEG;AAAuC,CAAC;AACpD;AACAC,OAAuD,EACvD;EACA,MAAMC,IAAI,GAAGZ,eAAe,CAACC,WAAW,CAAC;EACzC,MAAMY,MAAM,GAAGD,IAAI,CAACE,aAAa,CAACJ,GAAG,EAAEC,OAAO,CAAC;EAC/C,OAAO;IACLD,GAAG,EAAEG,MAAM,CAACE,GAAG;IACf;IACAC,GAAG,EAAEH,MAAM,CAACI;EACd,CAAC;AACH"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { JsTransformerConfig, JsTransformOptions, TransformResponse } from 'metro-transform-worker';
|
|
3
|
+
export declare function transform(config: JsTransformerConfig, projectRoot: string, filename: string, data: Buffer, options: JsTransformOptions): Promise<TransformResponse>;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transform = transform;
|
|
7
|
+
function _metroTransformWorker() {
|
|
8
|
+
const data = _interopRequireDefault(require("metro-transform-worker"));
|
|
9
|
+
_metroTransformWorker = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _css() {
|
|
15
|
+
const data = require("./css");
|
|
16
|
+
_css = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _cssModules() {
|
|
22
|
+
const data = require("./css-modules");
|
|
23
|
+
_cssModules = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _postcss() {
|
|
29
|
+
const data = require("./postcss");
|
|
30
|
+
_postcss = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _sass() {
|
|
36
|
+
const data = require("./sass");
|
|
37
|
+
_sass = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
44
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
45
|
+
const countLines = require('metro/src/lib/countLines');
|
|
46
|
+
async function transform(config, projectRoot, filename, data, options) {
|
|
47
|
+
var _jsModuleResults$outp2;
|
|
48
|
+
const isCss = options.type !== 'asset' && /\.(s?css|sass)$/.test(filename);
|
|
49
|
+
// If the file is not CSS, then use the default behavior.
|
|
50
|
+
if (!isCss) {
|
|
51
|
+
return _metroTransformWorker().default.transform(config, projectRoot, filename, data, options);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// If the platform is not web, then return an empty module.
|
|
55
|
+
if (options.platform !== 'web') {
|
|
56
|
+
const code = (0, _cssModules().matchCssModule)(filename) ? 'module.exports={};' : '';
|
|
57
|
+
return _metroTransformWorker().default.transform(config, projectRoot, filename,
|
|
58
|
+
// TODO: Native CSS Modules
|
|
59
|
+
Buffer.from(code), options);
|
|
60
|
+
}
|
|
61
|
+
let code = data.toString('utf8');
|
|
62
|
+
|
|
63
|
+
// Apply postcss transforms
|
|
64
|
+
code = await (0, _postcss().transformPostCssModule)(projectRoot, {
|
|
65
|
+
src: code,
|
|
66
|
+
filename
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// TODO: When native has CSS support, this will need to move higher up.
|
|
70
|
+
const syntax = (0, _sass().matchSass)(filename);
|
|
71
|
+
if (syntax) {
|
|
72
|
+
code = (0, _sass().compileSass)(projectRoot, {
|
|
73
|
+
filename,
|
|
74
|
+
src: code
|
|
75
|
+
}, {
|
|
76
|
+
syntax
|
|
77
|
+
}).src;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// If the file is a CSS Module, then transform it to a JS module
|
|
81
|
+
// in development and a static CSS file in production.
|
|
82
|
+
if ((0, _cssModules().matchCssModule)(filename)) {
|
|
83
|
+
var _jsModuleResults$outp;
|
|
84
|
+
const results = await (0, _cssModules().transformCssModuleWeb)({
|
|
85
|
+
filename,
|
|
86
|
+
src: code,
|
|
87
|
+
options: {
|
|
88
|
+
projectRoot,
|
|
89
|
+
dev: options.dev,
|
|
90
|
+
minify: options.minify,
|
|
91
|
+
sourceMap: false
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const jsModuleResults = await _metroTransformWorker().default.transform(config, projectRoot, filename, Buffer.from(results.output), options);
|
|
95
|
+
const cssCode = results.css.toString();
|
|
96
|
+
const output = [{
|
|
97
|
+
type: 'js/module',
|
|
98
|
+
data: {
|
|
99
|
+
// @ts-expect-error
|
|
100
|
+
...((_jsModuleResults$outp = jsModuleResults.output[0]) === null || _jsModuleResults$outp === void 0 ? void 0 : _jsModuleResults$outp.data),
|
|
101
|
+
// Append additional css metadata for static extraction.
|
|
102
|
+
css: {
|
|
103
|
+
code: cssCode,
|
|
104
|
+
lineCount: countLines(cssCode),
|
|
105
|
+
map: [],
|
|
106
|
+
functionMap: null
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}];
|
|
110
|
+
return {
|
|
111
|
+
dependencies: jsModuleResults.dependencies,
|
|
112
|
+
output
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Global CSS:
|
|
117
|
+
|
|
118
|
+
const {
|
|
119
|
+
transform
|
|
120
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('lightningcss')));
|
|
121
|
+
|
|
122
|
+
// TODO: Add bundling to resolve imports
|
|
123
|
+
// https://lightningcss.dev/bundling.html#bundling-order
|
|
124
|
+
|
|
125
|
+
const cssResults = transform({
|
|
126
|
+
filename,
|
|
127
|
+
code: Buffer.from(code),
|
|
128
|
+
sourceMap: false,
|
|
129
|
+
cssModules: false,
|
|
130
|
+
projectRoot,
|
|
131
|
+
minify: options.minify
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// TODO: Warnings:
|
|
135
|
+
// cssResults.warnings.forEach((warning) => {
|
|
136
|
+
// });
|
|
137
|
+
|
|
138
|
+
// Create a mock JS module that exports an empty object,
|
|
139
|
+
// this ensures Metro dependency graph is correct.
|
|
140
|
+
const jsModuleResults = await _metroTransformWorker().default.transform(config, projectRoot, filename, options.dev ? Buffer.from((0, _css().wrapDevelopmentCSS)({
|
|
141
|
+
src: code,
|
|
142
|
+
filename
|
|
143
|
+
})) : Buffer.from(''), options);
|
|
144
|
+
const cssCode = cssResults.code.toString();
|
|
145
|
+
|
|
146
|
+
// In production, we export the CSS as a string and use a special type to prevent
|
|
147
|
+
// it from being included in the JS bundle. We'll extract the CSS like an asset later
|
|
148
|
+
// and append it to the HTML bundle.
|
|
149
|
+
const output = [{
|
|
150
|
+
type: 'js/module',
|
|
151
|
+
data: {
|
|
152
|
+
// @ts-expect-error
|
|
153
|
+
...((_jsModuleResults$outp2 = jsModuleResults.output[0]) === null || _jsModuleResults$outp2 === void 0 ? void 0 : _jsModuleResults$outp2.data),
|
|
154
|
+
// Append additional css metadata for static extraction.
|
|
155
|
+
css: {
|
|
156
|
+
code: cssCode,
|
|
157
|
+
lineCount: countLines(cssCode),
|
|
158
|
+
map: [],
|
|
159
|
+
functionMap: null
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}];
|
|
163
|
+
return {
|
|
164
|
+
dependencies: jsModuleResults.dependencies,
|
|
165
|
+
output
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* A custom Metro transformer that adds support for processing Expo-specific bundler features.
|
|
171
|
+
* - Global CSS files on web.
|
|
172
|
+
* - CSS Modules on web.
|
|
173
|
+
* - TODO: Tailwind CSS on web.
|
|
174
|
+
*/
|
|
175
|
+
module.exports = {
|
|
176
|
+
// Use defaults for everything that's not custom.
|
|
177
|
+
..._metroTransformWorker().default,
|
|
178
|
+
transform
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=transform-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-worker.js","names":["_metroTransformWorker","data","_interopRequireDefault","require","_css","_cssModules","_postcss","_sass","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","countLines","transform","config","projectRoot","filename","options","_jsModuleResults$outp2","isCss","type","test","worker","platform","code","matchCssModule","Buffer","from","toString","transformPostCssModule","src","syntax","matchSass","compileSass","_jsModuleResults$outp","results","transformCssModuleWeb","dev","minify","sourceMap","jsModuleResults","output","cssCode","css","lineCount","map","functionMap","dependencies","Promise","resolve","then","cssResults","cssModules","wrapDevelopmentCSS","module","exports"],"sources":["../../src/transform-worker/transform-worker.ts"],"sourcesContent":["/**\n * Copyright 2023-present 650 Industries (Expo). All rights reserved.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { FBSourceFunctionMap, MetroSourceMapSegmentTuple } from 'metro-source-map';\nimport worker, {\n JsTransformerConfig,\n JsTransformOptions,\n TransformResponse,\n} from 'metro-transform-worker';\n\nimport { wrapDevelopmentCSS } from './css';\nimport { matchCssModule, transformCssModuleWeb } from './css-modules';\nimport { transformPostCssModule } from './postcss';\nimport { compileSass, matchSass } from './sass';\n\nconst countLines = require('metro/src/lib/countLines') as (string: string) => number;\n\ntype JSFileType = 'js/script' | 'js/module' | 'js/module/asset';\n\ntype JsOutput = {\n data: {\n code: string;\n lineCount: number;\n map: MetroSourceMapSegmentTuple[];\n functionMap: FBSourceFunctionMap | null;\n };\n type: JSFileType;\n};\n\nexport async function transform(\n config: JsTransformerConfig,\n projectRoot: string,\n filename: string,\n data: Buffer,\n options: JsTransformOptions\n): Promise<TransformResponse> {\n const isCss = options.type !== 'asset' && /\\.(s?css|sass)$/.test(filename);\n // If the file is not CSS, then use the default behavior.\n if (!isCss) {\n return worker.transform(config, projectRoot, filename, data, options);\n }\n\n // If the platform is not web, then return an empty module.\n if (options.platform !== 'web') {\n const code = matchCssModule(filename) ? 'module.exports={};' : '';\n return worker.transform(\n config,\n projectRoot,\n filename,\n // TODO: Native CSS Modules\n Buffer.from(code),\n options\n );\n }\n\n let code = data.toString('utf8');\n\n // Apply postcss transforms\n code = await transformPostCssModule(projectRoot, {\n src: code,\n filename,\n });\n\n // TODO: When native has CSS support, this will need to move higher up.\n const syntax = matchSass(filename);\n if (syntax) {\n code = compileSass(projectRoot, { filename, src: code }, { syntax }).src;\n }\n\n // If the file is a CSS Module, then transform it to a JS module\n // in development and a static CSS file in production.\n if (matchCssModule(filename)) {\n const results = await transformCssModuleWeb({\n filename,\n src: code,\n options: {\n projectRoot,\n dev: options.dev,\n minify: options.minify,\n sourceMap: false,\n },\n });\n\n const jsModuleResults = await worker.transform(\n config,\n projectRoot,\n filename,\n Buffer.from(results.output),\n options\n );\n\n const cssCode = results.css.toString();\n const output: JsOutput[] = [\n {\n type: 'js/module',\n data: {\n // @ts-expect-error\n ...jsModuleResults.output[0]?.data,\n\n // Append additional css metadata for static extraction.\n css: {\n code: cssCode,\n lineCount: countLines(cssCode),\n map: [],\n functionMap: null,\n },\n },\n },\n ];\n\n return {\n dependencies: jsModuleResults.dependencies,\n output,\n };\n }\n\n // Global CSS:\n\n const { transform } = await import('lightningcss');\n\n // TODO: Add bundling to resolve imports\n // https://lightningcss.dev/bundling.html#bundling-order\n\n const cssResults = transform({\n filename,\n code: Buffer.from(code),\n sourceMap: false,\n cssModules: false,\n projectRoot,\n minify: options.minify,\n });\n\n // TODO: Warnings:\n // cssResults.warnings.forEach((warning) => {\n // });\n\n // Create a mock JS module that exports an empty object,\n // this ensures Metro dependency graph is correct.\n const jsModuleResults = await worker.transform(\n config,\n projectRoot,\n filename,\n options.dev ? Buffer.from(wrapDevelopmentCSS({ src: code, filename })) : Buffer.from(''),\n options\n );\n\n const cssCode = cssResults.code.toString();\n\n // In production, we export the CSS as a string and use a special type to prevent\n // it from being included in the JS bundle. We'll extract the CSS like an asset later\n // and append it to the HTML bundle.\n const output: JsOutput[] = [\n {\n type: 'js/module',\n data: {\n // @ts-expect-error\n ...jsModuleResults.output[0]?.data,\n\n // Append additional css metadata for static extraction.\n css: {\n code: cssCode,\n lineCount: countLines(cssCode),\n map: [],\n functionMap: null,\n },\n },\n },\n ];\n\n return {\n dependencies: jsModuleResults.dependencies,\n output,\n };\n}\n\n/**\n * A custom Metro transformer that adds support for processing Expo-specific bundler features.\n * - Global CSS files on web.\n * - CSS Modules on web.\n * - TODO: Tailwind CSS on web.\n */\nmodule.exports = {\n // Use defaults for everything that's not custom.\n ...worker,\n transform,\n};\n"],"mappings":";;;;;;AAQA,SAAAA,sBAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,qBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgD,SAAAC,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WA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I;IAAER;EAAS,CAAC,CAAC,CAAC,GAAGU,MAAM,CAACC,IAAI,CAAC,EAAE,CAAC,EACxFV,OAAO,CACR;EAED,MAAMyB,OAAO,GAAGS,UAAU,CAAC3B,IAAI,CAACI,QAAQ,EAAE;;EAE1C;EACA;EACA;EACA,MAAMa,MAAkB,GAAG,CACzB;IACErB,IAAI,EAAE,WAAW;IACjBtC,IAAI,EAAE;MACJ;MACA,KAAAoC,sBAAA,GAAGsB,eAAe,CAACC,MAAM,CAAC,CAAC,CAAC,cAAAvB,sBAAA,uBAAzBA,sBAAA,CAA2BpC,IAAI;MAElC;MACA6D,GAAG,EAAE;QACHnB,IAAI,EAAEkB,OAAO;QACbE,SAAS,EAAEhC,UAAU,CAAC8B,OAAO,CAAC;QAC9BG,GAAG,EAAE,EAAE;QACPC,WAAW,EAAE;MACf;IACF;EACF,CAAC,CACF;EAED,OAAO;IACLC,YAAY,EAAEP,eAAe,CAACO,YAAY;IAC1CN;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACAa,MAAM,CAACC,OAAO,GAAG;EACf;EACA,GAAGjC,+BAAM;EACTT;AACF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.requireUncachedFile = requireUncachedFile;
|
|
7
|
+
exports.tryRequireThenImport = tryRequireThenImport;
|
|
8
|
+
async function tryRequireThenImport(moduleId) {
|
|
9
|
+
try {
|
|
10
|
+
return require(moduleId);
|
|
11
|
+
} catch (requireError) {
|
|
12
|
+
let importESM;
|
|
13
|
+
try {
|
|
14
|
+
// eslint-disable-next-line no-new-func
|
|
15
|
+
importESM = new Function('id', 'return import(id);');
|
|
16
|
+
} catch {
|
|
17
|
+
importESM = null;
|
|
18
|
+
}
|
|
19
|
+
if ((requireError === null || requireError === void 0 ? void 0 : requireError.code) === 'ERR_REQUIRE_ESM' && importESM) {
|
|
20
|
+
return (await importESM(moduleId)).default;
|
|
21
|
+
}
|
|
22
|
+
throw requireError;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function requireUncachedFile(moduleId) {
|
|
26
|
+
try {
|
|
27
|
+
// delete require.cache[require.resolve(moduleId)];
|
|
28
|
+
} catch {}
|
|
29
|
+
try {
|
|
30
|
+
return require(moduleId);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (error instanceof Error) {
|
|
33
|
+
error.message = `Cannot load file ${moduleId}: ${error.message}`;
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=require.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require.js","names":["tryRequireThenImport","moduleId","require","requireError","importESM","Function","code","default","requireUncachedFile","error","Error","message"],"sources":["../../../src/transform-worker/utils/require.ts"],"sourcesContent":["export async function tryRequireThenImport<TModule>(moduleId: string): Promise<TModule> {\n try {\n return require(moduleId);\n } catch (requireError: any) {\n let importESM;\n try {\n // eslint-disable-next-line no-new-func\n importESM = new Function('id', 'return import(id);');\n } catch {\n importESM = null;\n }\n\n if (requireError?.code === 'ERR_REQUIRE_ESM' && importESM) {\n return (await importESM(moduleId)).default;\n }\n\n throw requireError;\n }\n}\n\nexport function requireUncachedFile(moduleId: string) {\n try {\n // delete require.cache[require.resolve(moduleId)];\n } catch {}\n try {\n return require(moduleId);\n } catch (error: unknown) {\n if (error instanceof Error) {\n error.message = `Cannot load file ${moduleId}: ${error.message}`;\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;AAAO,eAAeA,oBAAoBA,CAAUC,QAAgB,EAAoB;EACtF,IAAI;IACF,OAAOC,OAAO,CAACD,QAAQ,CAAC;EAC1B,CAAC,CAAC,OAAOE,YAAiB,EAAE;IAC1B,IAAIC,SAAS;IACb,IAAI;MACF;MACAA,SAAS,GAAG,IAAIC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACtD,CAAC,CAAC,MAAM;MACND,SAAS,GAAG,IAAI;IAClB;IAEA,IAAI,CAAAD,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEG,IAAI,MAAK,iBAAiB,IAAIF,SAAS,EAAE;MACzD,OAAO,CAAC,MAAMA,SAAS,CAACH,QAAQ,CAAC,EAAEM,OAAO;IAC5C;IAEA,MAAMJ,YAAY;EACpB;AACF;AAEO,SAASK,mBAAmBA,CAACP,QAAgB,EAAE;EACpD,IAAI;IACF;EAAA,CACD,CAAC,MAAM,CAAC;EACT,IAAI;IACF,OAAOC,OAAO,CAACD,QAAQ,CAAC;EAC1B,CAAC,CAAC,OAAOQ,KAAc,EAAE;IACvB,IAAIA,KAAK,YAAYC,KAAK,EAAE;MAC1BD,KAAK,CAACE,OAAO,GAAI,oBAAmBV,QAAS,KAAIQ,KAAK,CAACE,OAAQ,EAAC;IAClE;IACA,MAAMF,KAAK;EACb;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExoticTransformer.js","names":["createExoticTransformer","nodeModulesPaths","transpileModules","nodeModuleMatcher","createModuleMatcher","folders","moduleIds","impossibleNodeModuleMatcher","transform","createMultiRuleTransformer","getRuleType","filename","test","rules","name","type","loaders","passthroughModule","warn","createReactNativeMatcher","reactNativeModule","createExpoMatcher","expoModule","createKnownCommunityMatcher","untranspiledModule","app","getCacheKey"],"sources":["../../src/transformer/createExoticTransformer.ts"],"sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\nimport { BabelTransformer } from 'metro-babel-transformer';\n\nimport {\n createExpoMatcher,\n createKnownCommunityMatcher,\n createModuleMatcher,\n createReactNativeMatcher,\n} from './createMatcher';\nimport { createMultiRuleTransformer, loaders } from './createMultiRuleTransformer';\nimport { getCacheKey } from './getCacheKey';\n\n/**\n * Create an experimental multi-rule transformer for a React Native app.\n *\n * @example\n * ```\n * module.exports = createExoticTransformer({\n * nodeModulesPaths: ['react-native'],\n * transpileModules: ['@stripe/stripe-react-native'],\n * });\n * ```\n *\n * @param props.nodeModulesPaths paths to node_modules folders, relative to project root. Default: `['node_modules']`\n * @param props.transpileModules matchers for module names that should be transpiled using the project Babel configuration. Example: `['@stripe/stripe-react-native']`\n * @returns a Metro `transformer` function and default `getCacheKey` function.\n */\nexport function createExoticTransformer({\n nodeModulesPaths,\n transpileModules,\n}: {\n nodeModulesPaths?: string[];\n transpileModules?: string[];\n}): BabelTransformer {\n if (!nodeModulesPaths) {\n nodeModulesPaths = ['node_modules'];\n }\n // Match any node modules, or monorepo module.\n const nodeModuleMatcher = createModuleMatcher({ folders: nodeModulesPaths, moduleIds: [] });\n\n // Match node modules which are so oddly written that we must\n // transpile them with every possible option (most expensive).\n const impossibleNodeModuleMatcher = createModuleMatcher({\n moduleIds: [\n // victory is too wild\n // SyntaxError in ../../node_modules/victory-native/lib/components/victory-primitives/bar.js: Missing semicolon. (9:1)\n 'victory',\n // vector icons has some hidden issues that break NCL\n '@expo/vector-icons',\n ...(transpileModules || []),\n ],\n folders: nodeModulesPaths,\n });\n\n const transform = createMultiRuleTransformer({\n // Specify which rules to use on a per-file basis, basically\n // this is used to determine which modules are node modules, and which are application code.\n getRuleType({ filename }) {\n // Is a node module, and is not one of the impossible modules.\n return nodeModuleMatcher.test(filename) && !impossibleNodeModuleMatcher.test(filename)\n ? 'module'\n : 'app';\n },\n\n // Order is very important, we use wild card matchers to transpile\n // \"every unhandled node module\" and \"every unhandled application module\".\n rules: [\n // Match bob compiler modules, use the passthrough loader.\n {\n name: 'bob',\n type: 'module',\n test: createModuleMatcher({ moduleIds: ['.*/lib/commonjs/'], folders: nodeModulesPaths }),\n transform: loaders.passthroughModule,\n warn: true,\n },\n // Match React Native modules, convert them statically using sucrase.\n {\n name: 'react-native',\n type: 'module',\n test: createReactNativeMatcher({ folders: nodeModulesPaths }),\n transform: loaders.reactNativeModule,\n warn: true,\n },\n // Match Expo SDK modules, convert them statically using sucrase.\n {\n name: 'expo-module',\n type: 'module',\n test: createExpoMatcher({ folders: nodeModulesPaths }),\n transform: loaders.expoModule,\n warn: true,\n },\n // Match known problematic modules, convert them statically using an expensive, dynamic sucrase.\n {\n name: 'sucrase',\n type: 'module',\n test: createKnownCommunityMatcher({\n folders: nodeModulesPaths,\n }),\n transform: loaders.untranspiledModule,\n warn: true,\n },\n // Pass through any unhandled node modules as passthrough, this is where the most savings occur.\n // Ideally, you want your project to pass all node modules through this loader.\n // This should be the last \"module\" rule.\n // Message library authors and ask them to ship their modules as pre-transpiled\n // commonjs, to improve the development speed of your project.\n {\n name: 'skip-module',\n type: 'module',\n test: () => true,\n transform: loaders.passthroughModule,\n },\n // All application code should be transpiled with the user's babel preset,\n // this is the most expensive operation but provides the most customization to the user.\n // The goal is to use this as sparingly as possible.\n {\n name: 'babel',\n test: () => true,\n transform: loaders.app,\n },\n ],\n });\n\n return {\n transform,\n getCacheKey,\n };\n}\n"],"mappings":";;;;;;AAGA;EAAA;
|
|
1
|
+
{"version":3,"file":"createExoticTransformer.js","names":["_createMatcher","data","require","_createMultiRuleTransformer","_getCacheKey","createExoticTransformer","nodeModulesPaths","transpileModules","nodeModuleMatcher","createModuleMatcher","folders","moduleIds","impossibleNodeModuleMatcher","transform","createMultiRuleTransformer","getRuleType","filename","test","rules","name","type","loaders","passthroughModule","warn","createReactNativeMatcher","reactNativeModule","createExpoMatcher","expoModule","createKnownCommunityMatcher","untranspiledModule","app","getCacheKey"],"sources":["../../src/transformer/createExoticTransformer.ts"],"sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\nimport { BabelTransformer } from 'metro-babel-transformer';\n\nimport {\n createExpoMatcher,\n createKnownCommunityMatcher,\n createModuleMatcher,\n createReactNativeMatcher,\n} from './createMatcher';\nimport { createMultiRuleTransformer, loaders } from './createMultiRuleTransformer';\nimport { getCacheKey } from './getCacheKey';\n\n/**\n * Create an experimental multi-rule transformer for a React Native app.\n *\n * @example\n * ```\n * module.exports = createExoticTransformer({\n * nodeModulesPaths: ['react-native'],\n * transpileModules: ['@stripe/stripe-react-native'],\n * });\n * ```\n *\n * @param props.nodeModulesPaths paths to node_modules folders, relative to project root. Default: `['node_modules']`\n * @param props.transpileModules matchers for module names that should be transpiled using the project Babel configuration. Example: `['@stripe/stripe-react-native']`\n * @returns a Metro `transformer` function and default `getCacheKey` function.\n */\nexport function createExoticTransformer({\n nodeModulesPaths,\n transpileModules,\n}: {\n nodeModulesPaths?: string[];\n transpileModules?: string[];\n}): BabelTransformer {\n if (!nodeModulesPaths) {\n nodeModulesPaths = ['node_modules'];\n }\n // Match any node modules, or monorepo module.\n const nodeModuleMatcher = createModuleMatcher({ folders: nodeModulesPaths, moduleIds: [] });\n\n // Match node modules which are so oddly written that we must\n // transpile them with every possible option (most expensive).\n const impossibleNodeModuleMatcher = createModuleMatcher({\n moduleIds: [\n // victory is too wild\n // SyntaxError in ../../node_modules/victory-native/lib/components/victory-primitives/bar.js: Missing semicolon. (9:1)\n 'victory',\n // vector icons has some hidden issues that break NCL\n '@expo/vector-icons',\n ...(transpileModules || []),\n ],\n folders: nodeModulesPaths,\n });\n\n const transform = createMultiRuleTransformer({\n // Specify which rules to use on a per-file basis, basically\n // this is used to determine which modules are node modules, and which are application code.\n getRuleType({ filename }) {\n // Is a node module, and is not one of the impossible modules.\n return nodeModuleMatcher.test(filename) && !impossibleNodeModuleMatcher.test(filename)\n ? 'module'\n : 'app';\n },\n\n // Order is very important, we use wild card matchers to transpile\n // \"every unhandled node module\" and \"every unhandled application module\".\n rules: [\n // Match bob compiler modules, use the passthrough loader.\n {\n name: 'bob',\n type: 'module',\n test: createModuleMatcher({ moduleIds: ['.*/lib/commonjs/'], folders: nodeModulesPaths }),\n transform: loaders.passthroughModule,\n warn: true,\n },\n // Match React Native modules, convert them statically using sucrase.\n {\n name: 'react-native',\n type: 'module',\n test: createReactNativeMatcher({ folders: nodeModulesPaths }),\n transform: loaders.reactNativeModule,\n warn: true,\n },\n // Match Expo SDK modules, convert them statically using sucrase.\n {\n name: 'expo-module',\n type: 'module',\n test: createExpoMatcher({ folders: nodeModulesPaths }),\n transform: loaders.expoModule,\n warn: true,\n },\n // Match known problematic modules, convert them statically using an expensive, dynamic sucrase.\n {\n name: 'sucrase',\n type: 'module',\n test: createKnownCommunityMatcher({\n folders: nodeModulesPaths,\n }),\n transform: loaders.untranspiledModule,\n warn: true,\n },\n // Pass through any unhandled node modules as passthrough, this is where the most savings occur.\n // Ideally, you want your project to pass all node modules through this loader.\n // This should be the last \"module\" rule.\n // Message library authors and ask them to ship their modules as pre-transpiled\n // commonjs, to improve the development speed of your project.\n {\n name: 'skip-module',\n type: 'module',\n test: () => true,\n transform: loaders.passthroughModule,\n },\n // All application code should be transpiled with the user's babel preset,\n // this is the most expensive operation but provides the most customization to the user.\n // The goal is to use this as sparingly as possible.\n {\n name: 'babel',\n test: () => true,\n transform: loaders.app,\n },\n ],\n });\n\n return {\n transform,\n getCacheKey,\n };\n}\n"],"mappings":";;;;;;AAGA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAE,4BAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,2BAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAVA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,uBAAuBA,CAAC;EACtCC,gBAAgB;EAChBC;AAIF,CAAC,EAAoB;EACnB,IAAI,CAACD,gBAAgB,EAAE;IACrBA,gBAAgB,GAAG,CAAC,cAAc,CA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S,EAAEQ,qCAAO,CAACM,UAAU;MAC7BJ,IAAI,EAAE;IACR,CAAC;IACD;IACA;MACEJ,IAAI,EAAE,SAAS;MACfC,IAAI,EAAE,QAAQ;MACdH,IAAI,EAAE,IAAAW,4CAA2B,EAAC;QAChClB,OAAO,EAAEJ;MACX,CAAC,CAAC;MACFO,SAAS,EAAEQ,qCAAO,CAACQ,kBAAkB;MACrCN,IAAI,EAAE;IACR,CAAC;IACD;IACA;IACA;IACA;IACA;IACA;MACEJ,IAAI,EAAE,aAAa;MACnBC,IAAI,EAAE,QAAQ;MACdH,IAAI,EAAEA,CAAA,KAAM,IAAI;MAChBJ,SAAS,EAAEQ,qCAAO,CAACC;IACrB,CAAC;IACD;IACA;IACA;IACA;MACEH,IAAI,EAAE,OAAO;MACbF,IAAI,EAAEA,CAAA,KAAM,IAAI;MAChBJ,SAAS,EAAEQ,qCAAO,CAACS;IACrB,CAAC;EAEL,CAAC,CAAC;EAEF,OAAO;IACLjB,SAAS;IACTkB,WAAW,EAAXA;EACF,CAAC;AACH"}
|
|
@@ -29,7 +29,7 @@ const createExpoMatcher = ({
|
|
|
29
29
|
}) => createModuleMatcher({
|
|
30
30
|
folders,
|
|
31
31
|
// We'll work to start reducing this.
|
|
32
|
-
moduleIds: ['expo', '@expo', '@
|
|
32
|
+
moduleIds: ['expo', '@expo', '@use-expo']
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
// TODO: Make this list as short as possible before releasing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMatcher.js","names":["createModuleMatcher","folders","moduleIds","modulePathsGroup","join","moduleMatchersGroup","moduleMatcherId","map","value","RegExp","createReactNativeMatcher","createExpoMatcher","createKnownCommunityMatcher"],"sources":["../../src/transformer/createMatcher.ts"],"sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nexport function createModuleMatcher({\n folders = ['node_modules'],\n moduleIds,\n}: {\n folders?: string[];\n moduleIds: string[];\n}) {\n const modulePathsGroup = folders.join('|');\n\n const moduleMatchersGroup = moduleIds.join('|');\n\n const moduleMatcherId =\n '^' + [modulePathsGroup, moduleMatchersGroup].map((value) => `(?:${value})`).join('/');\n\n return new RegExp(moduleMatcherId);\n}\n\nexport const createReactNativeMatcher = ({ folders }: { folders?: string[] }) =>\n createModuleMatcher({\n folders,\n moduleIds: ['react-native/'],\n });\n\nexport const createExpoMatcher = ({ folders }: { folders?: string[] }) =>\n createModuleMatcher({\n folders,\n // We'll work to start reducing this.\n moduleIds: ['expo', '@expo', '@
|
|
1
|
+
{"version":3,"file":"createMatcher.js","names":["createModuleMatcher","folders","moduleIds","modulePathsGroup","join","moduleMatchersGroup","moduleMatcherId","map","value","RegExp","createReactNativeMatcher","exports","createExpoMatcher","createKnownCommunityMatcher"],"sources":["../../src/transformer/createMatcher.ts"],"sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nexport function createModuleMatcher({\n folders = ['node_modules'],\n moduleIds,\n}: {\n folders?: string[];\n moduleIds: string[];\n}) {\n const modulePathsGroup = folders.join('|');\n\n const moduleMatchersGroup = moduleIds.join('|');\n\n const moduleMatcherId =\n '^' + [modulePathsGroup, moduleMatchersGroup].map((value) => `(?:${value})`).join('/');\n\n return new RegExp(moduleMatcherId);\n}\n\nexport const createReactNativeMatcher = ({ folders }: { folders?: string[] }) =>\n createModuleMatcher({\n folders,\n moduleIds: ['react-native/'],\n });\n\nexport const createExpoMatcher = ({ folders }: { folders?: string[] }) =>\n createModuleMatcher({\n folders,\n // We'll work to start reducing this.\n moduleIds: ['expo', '@expo', '@use-expo'],\n });\n\n// TODO: Make this list as short as possible before releasing.\n// TODO: Add SDK version compat list.\nexport const createKnownCommunityMatcher = ({\n folders,\n moduleIds = [],\n}: {\n folders?: string[];\n moduleIds?: string[];\n} = {}) =>\n createModuleMatcher({\n folders,\n moduleIds: [\n ...moduleIds,\n // The more complex, the longer the entire project takes...\n // react-native-community, react-native-masked-view, react-native-picker, react-native-segmented-control, react-native\n '@react-',\n // @sentry/react-native\n '@(?:[\\\\w|-]+)/react-native',\n 'react-native-',\n 'victory-',\n 'native-base',\n 'styled-components',\n // three.js\n 'three/build/three.module.js',\n 'three/examples/jsm',\n // Special case for testing expo/expo repo\n 'html-elements/',\n // shared-element\n 'react-navigation-',\n ],\n });\n"],"mappings":";;;;;;;;AAAA;;AAEO,SAASA,mBAAmBA,CAAC;EAClCC,OAAO,GAAG,CAAC,cAAc,CAAC;EAC1BC;AAIF,CAAC,EAAE;EACD,MAAMC,gBAAgB,GAAGF,OAAO,CAACG,IAAI,CAAC,GAAG,CAAC;EAE1C,MAAMC,mBAAmB,GAAGH,SAAS,CAACE,IAAI,CAAC,GAAG,CAAC;EAE/C,MAAME,eAAe,GACnB,GAAG,GAAG,CAACH,gBAAgB,EAAEE,mBAAmB,CAAC,CAACE,GAAG,CAAEC,KAAK,IAAM,MAAKA,KAAM,GAAE,CAAC,CAACJ,IAAI,CAAC,GAAG,CAAC;EAExF,OAAO,IAAIK,MAAM,CAACH,eAAe,CAAC;AACpC;AAEO,MAAMI,wBAAwB,GAAGA,CAAC;EAAET;AAAgC,CAAC,KAC1ED,mBAAmB,CAAC;EAClBC,OAAO;EACPC,SAAS,EAAE,CAAC,eAAe;AAC7B,CAAC,CAAC;AAACS,OAAA,CAAAD,wBAAA,GAAAA,wBAAA;AAEE,MAAME,iBAAiB,GAAGA,CAAC;EAAEX;AAAgC,CAAC,KACnED,mBAAmB,CAAC;EAClBC,OAAO;EACP;EACAC,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW;AAC1C,CAAC,CAAC;;AAEJ;AACA;AAAAS,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AACO,MAAMC,2BAA2B,GAAGA,CAAC;EAC1CZ,OAAO;EACPC,SAAS,GAAG;AAId,CAAC,GAAG,CAAC,CAAC,KACJF,mBAAmB,CAAC;EAClBC,OAAO;EACPC,SAAS,EAAE,CACT,GAAGA,SAAS;EACZ;EACA;EACA,SAAS;EACT;EACA,4BAA4B,EAC5B,eAAe,EACf,UAAU,EACV,aAAa,EACb,mBAAmB;EACnB;EACA,6BAA6B,EAC7B,oBAAoB;EACpB;EACA,gBAAgB;EAChB;EACA,mBAAmB;AAEvB,CAAC,CAAC;AAACS,OAAA,CAAAE,2BAAA,GAAAA,2BAAA"}
|
|
@@ -185,7 +185,7 @@ function app(args) {
|
|
|
185
185
|
const result = transformFromAstSync(sourceAst, src, babelConfig);
|
|
186
186
|
|
|
187
187
|
// TODO: Disable by default
|
|
188
|
-
const functionMap = (0, _generateFunctionMap().generateFunctionMap)(
|
|
188
|
+
const functionMap = (0, _generateFunctionMap().generateFunctionMap)(sourceAst, {
|
|
189
189
|
filename
|
|
190
190
|
});
|
|
191
191
|
// The result from `transformFromAstSync` can be null (if the file is ignored)
|
|
@@ -247,7 +247,7 @@ const loaders = {
|
|
|
247
247
|
const ast = parseAst(options.projectRoot, src);
|
|
248
248
|
|
|
249
249
|
// TODO: Disable by default
|
|
250
|
-
const functionMap = (0, _generateFunctionMap().generateFunctionMap)(
|
|
250
|
+
const functionMap = (0, _generateFunctionMap().generateFunctionMap)(ast, {
|
|
251
251
|
filename
|
|
252
252
|
});
|
|
253
253
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMultiRuleTransformer.js","names":["debug","Debug","babelCore","getBabelCoreFromProject","projectRoot","require","resolveFrom","babelParser","getBabelParserFromProject","sucrase","args","transforms","src","filename","options","dev","transform","results","filePath","production","code","functionMap","getExpensiveSucraseTransforms","test","parseAst","sourceCode","babylon","parse","sourceType","createMultiRuleTransformer","getRuleType","rules","OLD_BABEL_ENV","process","env","BABEL_ENV","ruleType","rule","type","isMatched","_ruleName","name","ast","Error","app","plugins","babelConfig","getBabelConfig","caller","platform","Object","defineProperty","enumerable","writable","value","onWarning","msg","console","warn","chalk","bold","yellow","parseSync","transformFromAstSync","sourceAst","result","generateFunctionMap","loaders","reactNativeModule","includes","expoModule","filter","Boolean","untranspiledModule","passthroughModule"],"sources":["../../src/transformer/createMultiRuleTransformer.ts"],"sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nimport chalk from 'chalk';\nimport Debug from 'debug';\nimport type { BabelTransformer, BabelTransformerArgs } from 'metro-babel-transformer';\nimport resolveFrom from 'resolve-from';\n\nimport { generateFunctionMap } from './generateFunctionMap';\nimport { getBabelConfig } from './getBabelConfig';\n\nconst debug = Debug('expo:metro:exotic-babel-transformer');\n\nlet babelCore: typeof import('@babel/core') | undefined;\n\nfunction getBabelCoreFromProject(projectRoot: string) {\n if (babelCore) return babelCore;\n babelCore = require(resolveFrom(projectRoot, '@babel/core'));\n return babelCore!;\n}\n\nlet babelParser: typeof import('@babel/parser') | undefined;\n\nfunction getBabelParserFromProject(projectRoot: string) {\n if (babelParser) return babelParser;\n babelParser = require(resolveFrom(projectRoot, '@babel/parser'));\n return babelParser!;\n}\n\nfunction sucrase(\n args: BabelTransformerArgs,\n {\n transforms,\n }: {\n transforms: string[];\n }\n): Partial<ReturnType<BabelTransformer['transform']>> {\n const {\n src,\n filename,\n options: { dev },\n } = args;\n const { transform } = require('sucrase');\n\n const results = transform(src, {\n filePath: filename,\n production: !dev,\n transforms,\n });\n\n return {\n code: results.code,\n functionMap: null,\n };\n}\n\nconst getExpensiveSucraseTransforms = (filename: string) => [\n 'jsx',\n 'imports',\n /\\.tsx?$/.test(filename) ? 'typescript' : 'flow',\n];\n\nfunction parseAst(projectRoot: string, sourceCode: string) {\n const babylon = getBabelParserFromProject(projectRoot);\n\n return babylon.parse(sourceCode, {\n sourceType: 'unambiguous',\n });\n}\n\nexport type Rule = {\n warn?: boolean;\n type?: 'module' | 'app';\n name?: string;\n test: ((args: BabelTransformerArgs) => boolean) | RegExp;\n transform: BabelTransformer['transform'];\n};\n\n/** Create a transformer that emulates Webpack's loader system. */\nexport function createMultiRuleTransformer({\n getRuleType,\n rules,\n}: {\n getRuleType: (args: BabelTransformerArgs) => string;\n rules: Rule[];\n}): BabelTransformer['transform'] {\n // const warnings: string[] = [];\n return function transform(args: BabelTransformerArgs) {\n const { filename, options } = args;\n const OLD_BABEL_ENV = process.env.BABEL_ENV;\n process.env.BABEL_ENV = options?.dev ? 'development' : process.env.BABEL_ENV || 'production';\n\n try {\n const ruleType = getRuleType(args);\n\n for (const rule of rules) {\n // optimization for checking node modules\n if (rule.type && rule.type !== ruleType) {\n continue;\n }\n\n const isMatched =\n typeof rule.test === 'function' ? rule.test(args) : rule.test.test(args.filename);\n if (isMatched) {\n const results = rule.transform(args);\n // @ts-ignore: Add extra property for testing\n results._ruleName = rule.name;\n // Perform a basic parse if none exists, this enables us to control the output, but only if it changed.\n if (results.code && !results.ast) {\n // Parse AST with babel otherwise Metro transformer will throw away the returned results.\n results.ast = parseAst(options?.projectRoot, results.code);\n }\n\n // TODO: Suboptimal warnings\n // if (rule.warn) {\n // const matchName =\n // filename.match(/node_modules\\/((:?@[\\w\\d-]+\\/[\\w\\d-]+)|(:?[\\w\\d-]+))\\/?/)?.[1] ??\n // filename;\n // if (matchName && !warnings.includes(matchName)) {\n // warnings.push(matchName);\n // console.warn(chalk.yellow.bold`warn `, matchName);\n // console.warn(\n // chalk.yellow`untranspiled module is potentially causing bundler slowdown, using modules that support commonjs will make your dev server much faster.`\n // );\n // }\n // }\n\n return results;\n }\n }\n throw new Error('no loader rule to handle file: ' + filename);\n } finally {\n if (OLD_BABEL_ENV) {\n process.env.BABEL_ENV = OLD_BABEL_ENV;\n }\n }\n };\n}\n\nfunction app(args: BabelTransformerArgs) {\n debug('app:', args.filename);\n\n const { filename, options, src, plugins } = args;\n const babelConfig = {\n // ES modules require sourceType='module' but OSS may not always want that\n sourceType: 'unambiguous',\n ...getBabelConfig(filename, options, plugins),\n // Variables that are exposed to the user's babel preset.\n caller: {\n name: 'metro',\n\n platform: options.platform,\n },\n ast: true,\n };\n\n // Surface a warning function so babel linters can be used.\n Object.defineProperty(babelConfig.caller, 'onWarning', {\n enumerable: false,\n writable: false,\n value: (babelConfig.caller.onWarning = function (msg: any) {\n // Format the file path first so users know where the warning came from.\n console.warn(chalk.bold.yellow`warn ` + args.filename);\n console.warn(msg);\n }),\n });\n\n const { parseSync, transformFromAstSync } = getBabelCoreFromProject(options.projectRoot);\n const sourceAst = parseSync(src, babelConfig);\n\n // Should never happen.\n if (!sourceAst) return { ast: null };\n\n const result = transformFromAstSync(sourceAst, src, babelConfig);\n\n // TODO: Disable by default\n const functionMap = generateFunctionMap(options.projectRoot, sourceAst, { filename });\n // The result from `transformFromAstSync` can be null (if the file is ignored)\n if (!result) {\n return { ast: null, functionMap };\n }\n\n return { ast: result.ast, functionMap };\n}\n\nexport const loaders: Record<string, (args: BabelTransformerArgs) => any> = {\n // Perform the standard, and most expensive transpilation sequence.\n app,\n\n // Transpile react-native with sucrase.\n reactNativeModule(args) {\n // Special file needs full transpilation.\n if (args.filename.includes('react-native/Libraries/Events/EventPolyfill.js')) {\n // Match React Native modules which use non-standard flow features, convert them using babel (most expensive).\n return app(args);\n }\n\n debug('rn:', args.filename);\n return sucrase(args, {\n transforms: ['jsx', 'flow', 'imports'],\n });\n },\n\n // Transpile expo modules with sucrase.\n expoModule(args) {\n debug('expo:', args.filename);\n // TODO: Fix all expo packages\n return sucrase(args, {\n transforms: [\n 'imports',\n // TODO: fix expo-processing, expo/vector-icons\n /(expo-processing|expo\\/vector-icons)/.test(args.filename) && 'jsx',\n // TODO: fix expo-asset-utils\n /(expo-asset-utils)/.test(args.filename) && 'flow',\n ].filter(Boolean) as string[],\n });\n },\n\n // Transpile known community modules with the most expensive sucrase\n untranspiledModule(args) {\n debug('known issues:', args.filename);\n return sucrase(args, {\n transforms: getExpensiveSucraseTransforms(args.filename),\n });\n },\n\n // Pass all modules through without transpiling them.\n passthroughModule(args) {\n const { filename, options, src } = args;\n debug('passthrough:', filename);\n\n // Perform a basic ast parse, this doesn't matter since the worker will parse and ignore anyways.\n const ast = parseAst(options.projectRoot, src);\n\n // TODO: Disable by default\n const functionMap = generateFunctionMap(options.projectRoot, ast, { filename });\n\n return {\n code: src,\n functionMap,\n ast,\n };\n },\n};\n"],"mappings":";;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAkD;AARlD;;AAUA,MAAMA,KAAK,GAAG,IAAAC,gBAAK,EAAC,qCAAqC,CAAC;AAE1D,IAAIC,SAAmD;AAEvD,SAASC,uBAAuB,CAACC,WAAmB,EAAE;EACpD,IAAIF,SAAS,EAAE,OAAOA,SAAS;EAC/BA,SAAS,GAAGG,OAAO,CAAC,IAAAC,sBAAW,EAACF,WAAW,EAAE,aAAa,CAAC,CAAC;EAC5D,OAAOF,SAAS;AAClB;AAEA,IAAIK,WAAuD;AAE3D,SAASC,yBAAyB,CAACJ,WAAmB,EAAE;EACtD,IAAIG,WAAW,EAAE,OAAOA,WAAW;EACnCA,WAAW,GAAGF,OAAO,CAAC,IAAAC,sBAAW,EAACF,WAAW,EAAE,eAAe,CAAC,CAAC;EAChE,OAAOG,WAAW;AACpB;AAEA,SAASE,OAAO,CACdC,IAA0B,EAC1B;EACEC;AAGF,CAAC,EACmD;EACpD,MAAM;IACJC,GAAG;IACHC,QAAQ;IACRC,OAAO,EAAE;MAAEC;IAAI;EACjB,CAAC,GAAGL,IAAI;EACR,MAAM;IAAEM;EAAU,CAAC,GAAGX,OAAO,CAAC,SAAS,CAAC;EAExC,MAAMY,OAAO,GAAGD,SAAS,CAACJ,GAAG,EAAE;IAC7BM,QAAQ,EAAEL,QAAQ;IAClBM,UAAU,EAAE,CAACJ,GAAG;IAChBJ;EACF,CAAC,CAAC;EAEF,OAAO;IACLS,IAAI,EAAEH,OAAO,CAACG,IAAI;IAClBC,WAAW,EAAE;EACf,CAAC;A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AC;IAC7B;IACA,OAAOJ,OAAO,CAACC,IAAI,EAAE;MACnBC,UAAU,EAAE,CACV,SAAS;MACT;MACA,sCAAsC,CAACY,IAAI,CAACb,IAAI,CAACG,QAAQ,CAAC,IAAI,KAAK;MACnE;MACA,oBAAoB,CAACU,IAAI,CAACb,IAAI,CAACG,QAAQ,CAAC,IAAI,MAAM,CACnD,CAAC0D,MAAM,CAACC,OAAO;IAClB,CAAC,CAAC;EACJ,CAAC;EAED;EACAC,kBAAkB,CAAC/D,IAAI,EAAE;IACvBV,KAAK,CAAC,eAAe,EAAEU,IAAI,CAACG,QAAQ,CAAC;IACrC,OAAOJ,OAAO,CAACC,IAAI,EAAE;MACnBC,UAAU,EAAEW,6BAA6B,CAACZ,IAAI,CAACG,QAAQ;IACzD,CAAC,CAAC;EACJ,CAAC;EAED;EACA6D,iBAAiB,CAAChE,IAAI,EAAE;IACtB,MAAM;MAAEG,QAAQ;MAAEC,OAAO;MAAEF;IAAI,CAAC,GAAGF,IAAI;IACvCV,KAAK,CAAC,cAAc,EAAEa,QAAQ,CAAC;;IAE/B;IACA,MAAM6B,GAAG,GAAGlB,QAAQ,CAACV,OAAO,CAACV,WAAW,EAAEQ,GAAG,CAAC;;IAE9C;IACA,MAAMS,WAAW,GAAG,IAAA6C,0CAAmB,EAACpD,OAAO,CAACV,WAAW,EAAEsC,GAAG,EAAE;MAAE7B;IAAS,CAAC,CAAC;IAE/E,OAAO;MACLO,IAAI,EAAER,GAAG;MACTS,WAAW;MACXqB;IACF,CAAC;EACH;AACF,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"file":"createMultiRuleTransformer.js","names":["_chalk","data","_interopRequireDefault","require","_debug","_resolveFrom","_generateFunctionMap","_getBabelConfig","obj","__esModule","default","debug","Debug","babelCore","getBabelCoreFromProject","projectRoot","resolveFrom","babelParser","getBabelParserFromProject","sucrase","args","transforms","src","filename","options","dev","transform","results","filePath","production","code","functionMap","getExpensiveSucraseTransforms","test","parseAst","sourceCode","babylon","parse","sourceType","createMultiRuleTransformer","getRuleType","rules","OLD_BABEL_ENV","process","env","BABEL_ENV","ruleType","rule","type","isMatched","_ruleName","name","ast","Error","app","plugins","babelConfig","getBabelConfig","caller","platform","Object","defineProperty","enumerable","writable","value","onWarning","msg","console","warn","chalk","bold","yellow","parseSync","transformFromAstSync","sourceAst","result","generateFunctionMap","loaders","reactNativeModule","includes","expoModule","filter","Boolean","untranspiledModule","passthroughModule","exports"],"sources":["../../src/transformer/createMultiRuleTransformer.ts"],"sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nimport chalk from 'chalk';\nimport Debug from 'debug';\nimport type { BabelTransformer, BabelTransformerArgs } from 'metro-babel-transformer';\nimport resolveFrom from 'resolve-from';\n\nimport { generateFunctionMap } from './generateFunctionMap';\nimport { getBabelConfig } from './getBabelConfig';\n\nconst debug = Debug('expo:metro:exotic-babel-transformer');\n\nlet babelCore: typeof import('@babel/core') | undefined;\n\nfunction getBabelCoreFromProject(projectRoot: string) {\n if (babelCore) return babelCore;\n babelCore = require(resolveFrom(projectRoot, '@babel/core'));\n return babelCore!;\n}\n\nlet babelParser: typeof import('@babel/parser') | undefined;\n\nfunction getBabelParserFromProject(projectRoot: string) {\n if (babelParser) return babelParser;\n babelParser = require(resolveFrom(projectRoot, '@babel/parser'));\n return babelParser!;\n}\n\nfunction sucrase(\n args: BabelTransformerArgs,\n {\n transforms,\n }: {\n transforms: string[];\n }\n): Partial<ReturnType<BabelTransformer['transform']>> {\n const {\n src,\n filename,\n options: { dev },\n } = args;\n const { transform } = require('sucrase');\n\n const results = transform(src, {\n filePath: filename,\n production: !dev,\n transforms,\n });\n\n return {\n code: results.code,\n functionMap: null,\n };\n}\n\nconst getExpensiveSucraseTransforms = (filename: string) => [\n 'jsx',\n 'imports',\n /\\.tsx?$/.test(filename) ? 'typescript' : 'flow',\n];\n\nfunction parseAst(projectRoot: string, sourceCode: string) {\n const babylon = getBabelParserFromProject(projectRoot);\n\n return babylon.parse(sourceCode, {\n sourceType: 'unambiguous',\n });\n}\n\nexport type Rule = {\n warn?: boolean;\n type?: 'module' | 'app';\n name?: string;\n test: ((args: BabelTransformerArgs) => boolean) | RegExp;\n transform: BabelTransformer['transform'];\n};\n\n/** Create a transformer that emulates Webpack's loader system. */\nexport function createMultiRuleTransformer({\n getRuleType,\n rules,\n}: {\n getRuleType: (args: BabelTransformerArgs) => string;\n rules: Rule[];\n}): BabelTransformer['transform'] {\n // const warnings: string[] = [];\n return function transform(args: BabelTransformerArgs) {\n const { filename, options } = args;\n const OLD_BABEL_ENV = process.env.BABEL_ENV;\n process.env.BABEL_ENV = options?.dev ? 'development' : process.env.BABEL_ENV || 'production';\n\n try {\n const ruleType = getRuleType(args);\n\n for (const rule of rules) {\n // optimization for checking node modules\n if (rule.type && rule.type !== ruleType) {\n continue;\n }\n\n const isMatched =\n typeof rule.test === 'function' ? rule.test(args) : rule.test.test(args.filename);\n if (isMatched) {\n const results = rule.transform(args);\n // @ts-ignore: Add extra property for testing\n results._ruleName = rule.name;\n // Perform a basic parse if none exists, this enables us to control the output, but only if it changed.\n if (results.code && !results.ast) {\n // Parse AST with babel otherwise Metro transformer will throw away the returned results.\n results.ast = parseAst(options?.projectRoot, results.code);\n }\n\n // TODO: Suboptimal warnings\n // if (rule.warn) {\n // const matchName =\n // filename.match(/node_modules\\/((:?@[\\w\\d-]+\\/[\\w\\d-]+)|(:?[\\w\\d-]+))\\/?/)?.[1] ??\n // filename;\n // if (matchName && !warnings.includes(matchName)) {\n // warnings.push(matchName);\n // console.warn(chalk.yellow.bold`warn `, matchName);\n // console.warn(\n // chalk.yellow`untranspiled module is potentially causing bundler slowdown, using modules that support commonjs will make your dev server much faster.`\n // );\n // }\n // }\n\n return results;\n }\n }\n throw new Error('no loader rule to handle file: ' + filename);\n } finally {\n if (OLD_BABEL_ENV) {\n process.env.BABEL_ENV = OLD_BABEL_ENV;\n }\n }\n };\n}\n\nfunction app(args: BabelTransformerArgs) {\n debug('app:', args.filename);\n\n const { filename, options, src, plugins } = args;\n const babelConfig = {\n // ES modules require sourceType='module' but OSS may not always want that\n sourceType: 'unambiguous',\n ...getBabelConfig(filename, options, plugins),\n // Variables that are exposed to the user's babel preset.\n caller: {\n name: 'metro',\n\n platform: options.platform,\n },\n ast: true,\n };\n\n // Surface a warning function so babel linters can be used.\n Object.defineProperty(babelConfig.caller, 'onWarning', {\n enumerable: false,\n writable: false,\n value: (babelConfig.caller.onWarning = function (msg: any) {\n // Format the file path first so users know where the warning came from.\n console.warn(chalk.bold.yellow`warn ` + args.filename);\n console.warn(msg);\n }),\n });\n\n const { parseSync, transformFromAstSync } = getBabelCoreFromProject(options.projectRoot);\n const sourceAst = parseSync(src, babelConfig);\n\n // Should never happen.\n if (!sourceAst) return { ast: null };\n\n const result = transformFromAstSync(sourceAst, src, babelConfig);\n\n // TODO: Disable by default\n const functionMap = generateFunctionMap(sourceAst, { filename });\n // The result from `transformFromAstSync` can be null (if the file is ignored)\n if (!result) {\n return { ast: null, functionMap };\n }\n\n return { ast: result.ast, functionMap };\n}\n\nexport const loaders: Record<string, (args: BabelTransformerArgs) => any> = {\n // Perform the standard, and most expensive transpilation sequence.\n app,\n\n // Transpile react-native with sucrase.\n reactNativeModule(args) {\n // Special file needs full transpilation.\n if (args.filename.includes('react-native/Libraries/Events/EventPolyfill.js')) {\n // Match React Native modules which use non-standard flow features, convert them using babel (most expensive).\n return app(args);\n }\n\n debug('rn:', args.filename);\n return sucrase(args, {\n transforms: ['jsx', 'flow', 'imports'],\n });\n },\n\n // Transpile expo modules with sucrase.\n expoModule(args) {\n debug('expo:', args.filename);\n // TODO: Fix all expo packages\n return sucrase(args, {\n transforms: [\n 'imports',\n // TODO: fix expo-processing, expo/vector-icons\n /(expo-processing|expo\\/vector-icons)/.test(args.filename) && 'jsx',\n // TODO: fix expo-asset-utils\n /(expo-asset-utils)/.test(args.filename) && 'flow',\n ].filter(Boolean) as string[],\n });\n },\n\n // Transpile known community modules with the most expensive sucrase\n untranspiledModule(args) {\n debug('known issues:', args.filename);\n return sucrase(args, {\n transforms: getExpensiveSucraseTransforms(args.filename),\n });\n },\n\n // Pass all modules through without transpiling them.\n passthroughModule(args) {\n const { filename, options, src } = args;\n debug('passthrough:', filename);\n\n // Perform a basic ast parse, this doesn't matter since the worker will parse and ignore anyways.\n const ast = parseAst(options.projectRoot, src);\n\n // TODO: Disable by default\n const functionMap = generateFunctionMap(ast, { filename });\n\n return {\n code: src,\n functionMap,\n ast,\n };\n },\n};\n"],"mappings":";;;;;;;AAEA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,aAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,qBAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,oBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,gBAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,eAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAkD,SAAAC,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AARlD;;AAUA,MAAMG,KAAK,GAAG,IAAAC,gBAAK,EAAC,qCAAqC,CAAC;AAE1D,IAAIC,SAAmD;AAEvD,SAASC,uBAA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EAAEW,6BAA6B,CAACZ,IAAI,CAACG,QAAQ;IACzD,CAAC,CAAC;EACJ,CAAC;EAED;EACA6D,iBAAiBA,CAAChE,IAAI,EAAE;IACtB,MAAM;MAAEG,QAAQ;MAAEC,OAAO;MAAEF;IAAI,CAAC,GAAGF,IAAI;IACvCT,KAAK,CAAC,cAAc,EAAEY,QAAQ,CAAC;;IAE/B;IACA,MAAM6B,GAAG,GAAGlB,QAAQ,CAACV,OAAO,CAACT,WAAW,EAAEO,GAAG,CAAC;;IAE9C;IACA,MAAMS,WAAW,GAAG,IAAA6C,0CAAmB,EAACxB,GAAG,EAAE;MAAE7B;IAAS,CAAC,CAAC;IAE1D,OAAO;MACLO,IAAI,EAAER,GAAG;MACTS,WAAW;MACXqB;IACF,CAAC;EACH;AACF,CAAC;AAACiC,OAAA,CAAAR,OAAA,GAAAA,OAAA"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { generateFunctionMap as generateFunctionMapType } from 'metro-source-map';
|
|
2
|
-
|
|
2
|
+
type GenerateFunctionMapParams = Parameters<typeof generateFunctionMapType>;
|
|
3
|
+
export declare function generateFunctionMap(...props: GenerateFunctionMapParams): ReturnType<typeof generateFunctionMapType> | null;
|
|
4
|
+
export {};
|
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.generateFunctionMap = generateFunctionMap;
|
|
7
|
-
function
|
|
8
|
-
const data = require("../
|
|
9
|
-
|
|
7
|
+
function _env() {
|
|
8
|
+
const data = require("../env");
|
|
9
|
+
_env = function () {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function generateFunctionMap(
|
|
14
|
+
function generateFunctionMap(...props) {
|
|
15
15
|
// `x_facebook_sources` is a source map feature that we disable by default since it isn't documented
|
|
16
16
|
// and doesn't appear to add much value to the DX, it also increases bundle time, and source map size.
|
|
17
17
|
// The feature supposedly provides improved function names for anonymous functions, but we will opt towards
|
|
@@ -30,8 +30,8 @@ function generateFunctionMap(projectRoot, ast, context) {
|
|
|
30
30
|
// - renderApplication renderApplication.js:54:5
|
|
31
31
|
// - run AppRegistry.js:117:26
|
|
32
32
|
//
|
|
33
|
-
if (
|
|
34
|
-
return (
|
|
33
|
+
if (_env().env.EXPO_USE_FB_SOURCES) {
|
|
34
|
+
return require('metro-source-map').generateFunctionMap(...props);
|
|
35
35
|
}
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateFunctionMap.js","names":["
|
|
1
|
+
{"version":3,"file":"generateFunctionMap.js","names":["_env","data","require","generateFunctionMap","props","env","EXPO_USE_FB_SOURCES"],"sources":["../../src/transformer/generateFunctionMap.ts"],"sourcesContent":["import type { generateFunctionMap as generateFunctionMapType } from 'metro-source-map';\n\nimport { env } from '../env';\n\ntype GenerateFunctionMapParams = Parameters<typeof generateFunctionMapType>;\n\nexport function generateFunctionMap(\n ...props: GenerateFunctionMapParams\n): ReturnType<typeof generateFunctionMapType> | null {\n // `x_facebook_sources` is a source map feature that we disable by default since it isn't documented\n // and doesn't appear to add much value to the DX, it also increases bundle time, and source map size.\n // The feature supposedly provides improved function names for anonymous functions, but we will opt towards\n // linting to prevent users from adding anonymous functions for important features like React components.\n //\n // Here is an example stack trace for a component that throws an error\n // in the root component (which is an anonymous function):\n //\n // Before:\n // - <anonymous> App.js:5:9\n // - renderApplication renderApplication.js:54:5\n // - runnables.appKey.run AppRegistry.js:117:26\n //\n // After:\n // - _default App.js:5:9\n // - renderApplication renderApplication.js:54:5\n // - run AppRegistry.js:117:26\n //\n if (env.EXPO_USE_FB_SOURCES) {\n return (require('metro-source-map') as typeof import('metro-source-map')).generateFunctionMap(\n ...props\n );\n }\n return null;\n}\n"],"mappings":";;;;;;AAEA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIO,SAASE,mBAAmBA,CACjC,GAAGC,KAAgC,EACgB;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAIC,UAAG,CAACC,mBAAmB,EAAE;IAC3B,OAAQJ,OAAO,CAAC,kBAAkB,CAAC,CAAuCC,mBAAmB,CAC3F,GAAGC,KAAK,CACT;EACH;EACA,OAAO,IAAI;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBabelConfig.js","names":["getBabelRC","babelRC","_getBabelRC","projectRoot","options","plugins","projectBabelRCPath","path","resolve","fs","existsSync","extends","experimentalImportSupport","presetOptions","presetPath","resolveFrom","silent","
|
|
1
|
+
{"version":3,"file":"getBabelConfig.js","names":["_fs","data","_interopRequireDefault","require","_path","_resolveFrom","obj","__esModule","default","getBabelRC","babelRC","_getBabelRC","projectRoot","options","plugins","projectBabelRCPath","path","resolve","fs","existsSync","extends","_ref","_resolveFrom$silent","experimentalImportSupport","presetOptions","presetPath","resolveFrom","silent","presets","jsxRuntime","disableImportExportTransform","enableBabelRuntime","getBabelConfig","filename","extraConfig","babelrc","enableBabelRCLookup","code","highlightCode","config","extraPlugins","inlineRequires","inlineRequiresPlugin","push","concat","dev","hot","mayContainEditableReactComponents","indexOf"],"sources":["../../src/transformer/getBabelConfig.ts"],"sourcesContent":["/**\n * Copyright (c) Expo.\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Forks the default metro-react-native-babel-transformer and adds support for known transforms.\n */\n\nimport type { PluginItem as BabelPlugins, PluginItem } from '@babel/core';\nimport fs from 'fs';\nimport type { BabelTransformerOptions } from 'metro-babel-transformer';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\n/**\n * Return a memoized function that checks for the existence of a\n * project level .babelrc file, and if it doesn't exist, reads the\n * default RN babelrc file and uses that.\n */\nconst getBabelRC = (function () {\n let babelRC: {\n // `any` to avoid flow type mismatch with Babel 7's internal type of\n // `Array<string>` even though it correctly accepts the usage below.\n presets?: any;\n extends?: string;\n plugins: BabelPlugins;\n } | null = null;\n\n return function _getBabelRC(projectRoot: string, options: BabelTransformerOptions) {\n if (babelRC != null) {\n return babelRC;\n }\n\n babelRC = { plugins: [] };\n\n // Let's look for a babel config file in the project root.\n // TODO look into adding a command line option to specify this location\n let projectBabelRCPath;\n\n // .babelrc\n if (projectRoot) {\n projectBabelRCPath = path.resolve(projectRoot, '.babelrc');\n }\n\n if (projectBabelRCPath) {\n // .babelrc.js\n if (!fs.existsSync(projectBabelRCPath)) {\n projectBabelRCPath = path.resolve(projectRoot, '.babelrc.js');\n }\n\n // babel.config.js\n if (!fs.existsSync(projectBabelRCPath)) {\n projectBabelRCPath = path.resolve(projectRoot, 'babel.config.js');\n }\n\n // If we found a babel config file, extend our config off of it\n // otherwise the default config will be used\n if (fs.existsSync(projectBabelRCPath)) {\n babelRC.extends = projectBabelRCPath;\n }\n }\n\n // If a babel config file doesn't exist in the project then\n // the default preset for react-native will be used instead.\n if (!babelRC.extends) {\n const { experimentalImportSupport, ...presetOptions } = options;\n\n // Use `babel-preset-expo` instead of `metro-react-native-babel-preset`.\n const presetPath =\n resolveFrom.silent(projectRoot, 'babel-preset-expo') ??\n resolveFrom.silent(projectRoot, 'metro-react-native-babel-preset') ??\n require.resolve('babel-preset-expo');\n\n babelRC.presets = [\n [\n require(presetPath),\n {\n // Default to React 17 automatic JSX transform.\n jsxRuntime: 'automatic',\n ...presetOptions,\n disableImportExportTransform: experimentalImportSupport,\n enableBabelRuntime: options.enableBabelRuntime,\n },\n ],\n ];\n }\n\n return babelRC;\n };\n})();\n\n/**\n * Given a filename and options, build a Babel\n * config object with the appropriate plugins.\n */\nexport function getBabelConfig(\n filename: string,\n options: BabelTransformerOptions,\n plugins: BabelPlugins = []\n) {\n const babelRC = getBabelRC(options.projectRoot, options);\n\n const extraConfig = {\n babelrc: typeof options.enableBabelRCLookup === 'boolean' ? options.enableBabelRCLookup : true,\n code: false,\n filename,\n highlightCode: true,\n };\n\n const config: any = { ...babelRC, ...extraConfig };\n\n // Add extra plugins\n const extraPlugins: (string | PluginItem)[] = [];\n\n // TODO: This probably can be removed\n if (options.inlineRequires) {\n const inlineRequiresPlugin = resolveFrom(\n options.projectRoot,\n 'babel-preset-fbjs/plugins/inline-requires'\n );\n extraPlugins.push(inlineRequiresPlugin);\n }\n\n config.plugins = extraPlugins.concat(config.plugins, plugins);\n\n if (options.dev && options.hot) {\n // Note: this intentionally doesn't include the path separator because\n // I'm not sure which one it should use on Windows, and false positives\n // are unlikely anyway. If you later decide to include the separator,\n // don't forget that the string usually *starts* with \"node_modules\" so\n // the first one often won't be there.\n // TODO: Support monorepos\n const mayContainEditableReactComponents = filename.indexOf('node_modules') === -1;\n\n if (mayContainEditableReactComponents) {\n if (!config.plugins) {\n config.plugins = [];\n }\n // Add react refresh runtime.\n // NOTICE: keep in sync with 'metro-react-native-babel-preset/src/configs/hmr'.\n config.plugins.push(resolveFrom.silent(options.projectRoot, 'react-refresh/babel'));\n }\n }\n\n return { ...babelRC, ...config };\n}\n"],"mappings":";;;;;;AAWA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,aAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AA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AO,EAAEA,OAAO,CAAC;EAE7D,IAAID,OAAO,CAACgC,GAAG,IAAIhC,OAAO,CAACiC,GAAG,EAAE;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA,MAAMC,iCAAiC,GAAGd,QAAQ,CAACe,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAEjF,IAAID,iCAAiC,EAAE;MACrC,IAAI,CAACR,MAAM,CAACzB,OAAO,EAAE;QACnByB,MAAM,CAACzB,OAAO,GAAG,EAAE;MACrB;MACA;MACA;MACAyB,MAAM,CAACzB,OAAO,CAAC6B,IAAI,CAACjB,sBAAW,CAACC,MAAM,CAACd,OAAO,CAACD,WAAW,EAAE,qBAAqB,CAAC,CAAC;IACrF;EACF;EAEA,OAAO;IAAE,GAAGF,OAAO;IAAE,GAAG6B;EAAO,CAAC;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCacheKey.js","names":["cacheKeyParts","readFileSync","__filename","process","env","EXPO_METRO_CACHE_KEY_VERSION","getCacheKey","key","crypto","createHash","forEach","part","update","digest"],"sources":["../../src/transformer/getCacheKey.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { readFileSync } from 'fs';\n\nexport const cacheKeyParts = [\n readFileSync(__filename),\n // Since babel-preset-fbjs cannot be safely resolved relative to the\n // project root, use this environment variable that we define earlier.\n process.env.EXPO_METRO_CACHE_KEY_VERSION || '3.3.0',\n // require('babel-preset-fbjs/package.json').version,\n];\n\n// Matches upstream\nexport function getCacheKey(): string {\n const key = crypto.createHash('md5');\n cacheKeyParts.forEach((part) => key.update(part));\n return key.digest('hex');\n}\n"],"mappings":";;;;;;;AAAA;EAAA;
|
|
1
|
+
{"version":3,"file":"getCacheKey.js","names":["_crypto","data","_interopRequireDefault","require","_fs","obj","__esModule","default","cacheKeyParts","readFileSync","__filename","process","env","EXPO_METRO_CACHE_KEY_VERSION","exports","getCacheKey","key","crypto","createHash","forEach","part","update","digest"],"sources":["../../src/transformer/getCacheKey.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { readFileSync } from 'fs';\n\nexport const cacheKeyParts = [\n readFileSync(__filename),\n // Since babel-preset-fbjs cannot be safely resolved relative to the\n // project root, use this environment variable that we define earlier.\n process.env.EXPO_METRO_CACHE_KEY_VERSION || '3.3.0',\n // require('babel-preset-fbjs/package.json').version,\n];\n\n// Matches upstream\nexport function getCacheKey(): string {\n const key = crypto.createHash('md5');\n cacheKeyParts.forEach((part) => key.update(part));\n return key.digest('hex');\n}\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,IAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,GAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAkC,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3B,MAAMG,aAAa,GAAG,CAC3B,IAAAC,kBAAY,EAACC,UAAU,CAAC;AACxB;AACA;AACAC,OAAO,CAACC,GAAG,CAACC,4BAA4B,IAAI;AAC5C;AAAA,CACD;;AAED;AAAAC,OAAA,CAAAN,aAAA,GAAAA,aAAA;AACO,SAASO,WAAWA,CAAA,EAAW;EACpC,MAAMC,GAAG,GAAGC,iBAAM,CAACC,UAAU,CAAC,KAAK,CAAC;EACpCV,aAAa,CAACW,OAAO,CAAEC,IAAI,IAAKJ,GAAG,CAACK,MAAM,CAACD,IAAI,CAAC,CAAC;EACjD,OAAOJ,GAAG,CAACM,MAAM,CAAC,KAAK,CAAC;AAC1B"}
|