metro-transform-worker 0.83.1 → 0.83.2
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/package.json +8 -8
- package/src/index.d.ts +14 -2
- package/src/index.js +174 -134
- package/src/index.js.flow +113 -108
- package/src/utils/assetTransformer.js +15 -11
- package/src/utils/assetTransformer.js.flow +4 -10
- package/src/utils/getMinifier.js +5 -2
- package/src/utils/getMinifier.js.flow +2 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-transform-worker",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.2",
|
|
4
4
|
"description": "🚇 Transform worker for Metro.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"@babel/parser": "^7.25.3",
|
|
24
24
|
"@babel/types": "^7.25.2",
|
|
25
25
|
"flow-enums-runtime": "^0.0.6",
|
|
26
|
-
"metro": "0.83.
|
|
27
|
-
"metro-babel-transformer": "0.83.
|
|
28
|
-
"metro-cache": "0.83.
|
|
29
|
-
"metro-cache-key": "0.83.
|
|
30
|
-
"metro-minify-terser": "0.83.
|
|
31
|
-
"metro-source-map": "0.83.
|
|
32
|
-
"metro-transform-plugins": "0.83.
|
|
26
|
+
"metro": "0.83.2",
|
|
27
|
+
"metro-babel-transformer": "0.83.2",
|
|
28
|
+
"metro-cache": "0.83.2",
|
|
29
|
+
"metro-cache-key": "0.83.2",
|
|
30
|
+
"metro-minify-terser": "0.83.2",
|
|
31
|
+
"metro-source-map": "0.83.2",
|
|
32
|
+
"metro-transform-plugins": "0.83.2",
|
|
33
33
|
"nullthrows": "^1.1.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
package/src/index.d.ts
CHANGED
|
@@ -78,7 +78,6 @@ export type JsTransformOptions = Readonly<{
|
|
|
78
78
|
customTransformOptions?: CustomTransformOptions;
|
|
79
79
|
dev: boolean;
|
|
80
80
|
experimentalImportSupport?: boolean;
|
|
81
|
-
hot: boolean;
|
|
82
81
|
inlinePlatform: boolean;
|
|
83
82
|
inlineRequires: boolean;
|
|
84
83
|
minify: boolean;
|
|
@@ -86,7 +85,6 @@ export type JsTransformOptions = Readonly<{
|
|
|
86
85
|
platform?: string;
|
|
87
86
|
runtimeBytecodeVersion?: number;
|
|
88
87
|
type: Type;
|
|
89
|
-
unstable_disableES6Transforms?: boolean;
|
|
90
88
|
unstable_transformProfile: TransformProfile;
|
|
91
89
|
}>;
|
|
92
90
|
|
|
@@ -124,3 +122,17 @@ export function transform(
|
|
|
124
122
|
): Promise<TransformResponse>;
|
|
125
123
|
|
|
126
124
|
export function getCacheKey(config: JsTransformerConfig): string;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Backwards-compatibility with CommonJS consumers using interopRequireDefault.
|
|
128
|
+
* Do not add to this list.
|
|
129
|
+
*
|
|
130
|
+
* @deprecated Default import from 'metro-transform-worker' is deprecated, use named exports.
|
|
131
|
+
*/
|
|
132
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: {
|
|
133
|
+
getCacheKey: typeof getCacheKey;
|
|
134
|
+
transform: typeof transform;
|
|
135
|
+
};
|
|
136
|
+
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
|
|
137
|
+
typeof $$EXPORT_DEFAULT_DECLARATION$$;
|
|
138
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
package/src/index.js
CHANGED
|
@@ -1,30 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.transform = exports.getCacheKey = exports.default = void 0;
|
|
7
|
+
var assetTransformer = _interopRequireWildcard(
|
|
8
|
+
require("./utils/assetTransformer"),
|
|
9
|
+
);
|
|
10
|
+
var _getMinifier = _interopRequireDefault(require("./utils/getMinifier"));
|
|
11
|
+
var _core = require("@babel/core");
|
|
12
|
+
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
13
|
+
var babylon = _interopRequireWildcard(require("@babel/parser"));
|
|
14
|
+
var types = _interopRequireWildcard(require("@babel/types"));
|
|
15
|
+
var _metroCache = require("metro-cache");
|
|
16
|
+
var _metroCacheKey = require("metro-cache-key");
|
|
17
|
+
var _metroSourceMap = require("metro-source-map");
|
|
18
|
+
var _metroTransformPlugins = _interopRequireDefault(
|
|
19
|
+
require("metro-transform-plugins"),
|
|
20
|
+
);
|
|
21
|
+
var _collectDependencies = _interopRequireDefault(
|
|
22
|
+
require("metro/private/ModuleGraph/worker/collectDependencies"),
|
|
23
|
+
);
|
|
24
|
+
var _generateImportNames = _interopRequireDefault(
|
|
25
|
+
require("metro/private/ModuleGraph/worker/generateImportNames"),
|
|
26
|
+
);
|
|
27
|
+
var _importLocationsPlugin = require("metro/private/ModuleGraph/worker/importLocationsPlugin");
|
|
28
|
+
var JsFileWrapping = _interopRequireWildcard(
|
|
29
|
+
require("metro/private/ModuleGraph/worker/JsFileWrapping"),
|
|
30
|
+
);
|
|
31
|
+
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
32
|
+
function _interopRequireDefault(e) {
|
|
33
|
+
return e && e.__esModule ? e : { default: e };
|
|
34
|
+
}
|
|
35
|
+
function _getRequireWildcardCache(e) {
|
|
36
|
+
if ("function" != typeof WeakMap) return null;
|
|
37
|
+
var r = new WeakMap(),
|
|
38
|
+
t = new WeakMap();
|
|
39
|
+
return (_getRequireWildcardCache = function (e) {
|
|
40
|
+
return e ? t : r;
|
|
41
|
+
})(e);
|
|
42
|
+
}
|
|
43
|
+
function _interopRequireWildcard(e, r) {
|
|
44
|
+
if (!r && e && e.__esModule) return e;
|
|
45
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
46
|
+
return { default: e };
|
|
47
|
+
var t = _getRequireWildcardCache(r);
|
|
48
|
+
if (t && t.has(e)) return t.get(e);
|
|
49
|
+
var n = { __proto__: null },
|
|
50
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
51
|
+
for (var u in e)
|
|
52
|
+
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
53
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
54
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
55
|
+
}
|
|
56
|
+
return ((n.default = e), t && t.set(e, n), n);
|
|
57
|
+
}
|
|
58
|
+
const InternalInvalidRequireCallError =
|
|
59
|
+
_collectDependencies.default.InvalidRequireCallError;
|
|
28
60
|
function getDynamicDepsBehavior(inPackages, filename) {
|
|
29
61
|
switch (inPackages) {
|
|
30
62
|
case "reject":
|
|
@@ -35,7 +67,7 @@ function getDynamicDepsBehavior(inPackages, filename) {
|
|
|
35
67
|
default:
|
|
36
68
|
inPackages;
|
|
37
69
|
throw new Error(
|
|
38
|
-
`invalid value for dynamic deps behavior: \`${inPackages}
|
|
70
|
+
`invalid value for dynamic deps behavior: \`${inPackages}\``,
|
|
39
71
|
);
|
|
40
72
|
}
|
|
41
73
|
}
|
|
@@ -46,9 +78,9 @@ const minifyCode = async (
|
|
|
46
78
|
code,
|
|
47
79
|
source,
|
|
48
80
|
map,
|
|
49
|
-
reserved = []
|
|
81
|
+
reserved = [],
|
|
50
82
|
) => {
|
|
51
|
-
const sourceMap = fromRawMappings([
|
|
83
|
+
const sourceMap = (0, _metroSourceMap.fromRawMappings)([
|
|
52
84
|
{
|
|
53
85
|
code,
|
|
54
86
|
source,
|
|
@@ -58,7 +90,7 @@ const minifyCode = async (
|
|
|
58
90
|
isIgnored: false,
|
|
59
91
|
},
|
|
60
92
|
]).toMap(undefined, {});
|
|
61
|
-
const minify =
|
|
93
|
+
const minify = (0, _getMinifier.default)(config.minifierPath);
|
|
62
94
|
try {
|
|
63
95
|
const minified = await minify({
|
|
64
96
|
code,
|
|
@@ -70,13 +102,15 @@ const minifyCode = async (
|
|
|
70
102
|
return {
|
|
71
103
|
code: minified.code,
|
|
72
104
|
map: minified.map
|
|
73
|
-
? toBabelSegments(minified.map).map(
|
|
105
|
+
? (0, _metroSourceMap.toBabelSegments)(minified.map).map(
|
|
106
|
+
_metroSourceMap.toSegmentTuple,
|
|
107
|
+
)
|
|
74
108
|
: [],
|
|
75
109
|
};
|
|
76
110
|
} catch (error) {
|
|
77
111
|
if (error.constructor.name === "JS_Parse_Error") {
|
|
78
112
|
throw new Error(
|
|
79
|
-
`${error.message} in file ${filename} at ${error.line}:${error.col}
|
|
113
|
+
`${error.message} in file ${filename} at ${error.line}:${error.col}`,
|
|
80
114
|
);
|
|
81
115
|
}
|
|
82
116
|
throw error;
|
|
@@ -102,7 +136,7 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
102
136
|
babylon.parse(file.code, {
|
|
103
137
|
sourceType: "unambiguous",
|
|
104
138
|
});
|
|
105
|
-
const { importDefault, importAll } =
|
|
139
|
+
const { importDefault, importAll } = (0, _generateImportNames.default)(ast);
|
|
106
140
|
const { directives } = ast.program;
|
|
107
141
|
if (
|
|
108
142
|
ast.program.sourceType === "module" &&
|
|
@@ -114,7 +148,7 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
114
148
|
const plugins = [];
|
|
115
149
|
if (options.experimentalImportSupport === true) {
|
|
116
150
|
plugins.push([
|
|
117
|
-
|
|
151
|
+
_metroTransformPlugins.default.importExportPlugin,
|
|
118
152
|
{
|
|
119
153
|
importAll,
|
|
120
154
|
importDefault,
|
|
@@ -124,7 +158,7 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
124
158
|
}
|
|
125
159
|
if (options.inlineRequires) {
|
|
126
160
|
plugins.push([
|
|
127
|
-
|
|
161
|
+
_metroTransformPlugins.default.inlineRequiresPlugin,
|
|
128
162
|
{
|
|
129
163
|
ignoredRequires: options.nonInlinedRequires,
|
|
130
164
|
inlineableCalls: [importDefault, importAll],
|
|
@@ -136,7 +170,7 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
136
170
|
]);
|
|
137
171
|
}
|
|
138
172
|
plugins.push([
|
|
139
|
-
|
|
173
|
+
_metroTransformPlugins.default.inlinePlugin,
|
|
140
174
|
{
|
|
141
175
|
dev: options.dev,
|
|
142
176
|
inlinePlatform: options.inlinePlatform,
|
|
@@ -144,8 +178,8 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
144
178
|
platform: options.platform,
|
|
145
179
|
},
|
|
146
180
|
]);
|
|
147
|
-
ast =
|
|
148
|
-
transformFromAstSync(ast, "", {
|
|
181
|
+
ast = (0, _nullthrows.default)(
|
|
182
|
+
(0, _core.transformFromAstSync)(ast, "", {
|
|
149
183
|
ast: true,
|
|
150
184
|
babelrc: false,
|
|
151
185
|
code: false,
|
|
@@ -155,21 +189,21 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
155
189
|
plugins,
|
|
156
190
|
sourceMaps: false,
|
|
157
191
|
cloneInputAst: true,
|
|
158
|
-
}).ast
|
|
192
|
+
}).ast,
|
|
159
193
|
);
|
|
160
194
|
if (!options.dev) {
|
|
161
|
-
ast =
|
|
162
|
-
transformFromAstSync(ast, "", {
|
|
195
|
+
ast = (0, _nullthrows.default)(
|
|
196
|
+
(0, _core.transformFromAstSync)(ast, "", {
|
|
163
197
|
ast: true,
|
|
164
198
|
babelrc: false,
|
|
165
199
|
code: false,
|
|
166
200
|
configFile: false,
|
|
167
201
|
comments: true,
|
|
168
202
|
filename: file.filename,
|
|
169
|
-
plugins: [
|
|
203
|
+
plugins: [_metroTransformPlugins.default.constantFoldingPlugin],
|
|
170
204
|
sourceMaps: false,
|
|
171
205
|
cloneInputAst: false,
|
|
172
|
-
}).ast
|
|
206
|
+
}).ast,
|
|
173
207
|
);
|
|
174
208
|
}
|
|
175
209
|
let dependencyMapName = "";
|
|
@@ -189,7 +223,7 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
189
223
|
: undefined,
|
|
190
224
|
dynamicRequires: getDynamicDepsBehavior(
|
|
191
225
|
config.dynamicDepsInPackages,
|
|
192
|
-
file.filename
|
|
226
|
+
file.filename,
|
|
193
227
|
),
|
|
194
228
|
inlineableCalls: [importDefault, importAll],
|
|
195
229
|
keepRequireNames: options.dev,
|
|
@@ -198,13 +232,14 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
198
232
|
unstable_allowRequireContext: config.unstable_allowRequireContext,
|
|
199
233
|
unstable_isESMImportAtSource:
|
|
200
234
|
importDeclarationLocs != null
|
|
201
|
-
? (loc) =>
|
|
235
|
+
? (loc) =>
|
|
236
|
+
importDeclarationLocs.has(
|
|
237
|
+
(0, _importLocationsPlugin.locToKey)(loc),
|
|
238
|
+
)
|
|
202
239
|
: null,
|
|
203
240
|
};
|
|
204
|
-
({ ast, dependencies, dependencyMapName } =
|
|
205
|
-
|
|
206
|
-
opts
|
|
207
|
-
));
|
|
241
|
+
({ ast, dependencies, dependencyMapName } = (0,
|
|
242
|
+
_collectDependencies.default)(ast, opts));
|
|
208
243
|
} catch (error) {
|
|
209
244
|
if (error instanceof InternalInvalidRequireCallError) {
|
|
210
245
|
throw new InvalidRequireCallError(error, file.filename);
|
|
@@ -224,9 +259,9 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
224
259
|
{
|
|
225
260
|
unstable_useStaticHermesModuleFactory: Boolean(
|
|
226
261
|
options.customTransformOptions
|
|
227
|
-
?.unstable_staticHermesOptimizedRequire
|
|
262
|
+
?.unstable_staticHermesOptimizedRequire,
|
|
228
263
|
),
|
|
229
|
-
}
|
|
264
|
+
},
|
|
230
265
|
));
|
|
231
266
|
}
|
|
232
267
|
}
|
|
@@ -244,12 +279,12 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
244
279
|
!config.unstable_disableNormalizePseudoGlobals
|
|
245
280
|
) {
|
|
246
281
|
reserved.push(
|
|
247
|
-
...
|
|
282
|
+
..._metroTransformPlugins.default.normalizePseudoGlobals(wrappedAst, {
|
|
248
283
|
reservedNames: reserved,
|
|
249
|
-
})
|
|
284
|
+
}),
|
|
250
285
|
);
|
|
251
286
|
}
|
|
252
|
-
const result =
|
|
287
|
+
const result = (0, _generator.default)(
|
|
253
288
|
wrappedAst,
|
|
254
289
|
{
|
|
255
290
|
comments: true,
|
|
@@ -259,9 +294,11 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
259
294
|
sourceFileName: file.filename,
|
|
260
295
|
sourceMaps: true,
|
|
261
296
|
},
|
|
262
|
-
file.code
|
|
297
|
+
file.code,
|
|
263
298
|
);
|
|
264
|
-
let map = result.rawMappings
|
|
299
|
+
let map = result.rawMappings
|
|
300
|
+
? result.rawMappings.map(_metroSourceMap.toSegmentTuple)
|
|
301
|
+
: [];
|
|
265
302
|
let code = result.code;
|
|
266
303
|
if (minify) {
|
|
267
304
|
({ map, code } = await minifyCode(
|
|
@@ -271,7 +308,7 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
271
308
|
result.code,
|
|
272
309
|
file.code,
|
|
273
310
|
map,
|
|
274
|
-
reserved
|
|
311
|
+
reserved,
|
|
275
312
|
));
|
|
276
313
|
}
|
|
277
314
|
let lineCount;
|
|
@@ -293,12 +330,11 @@ async function transformJS(file, { config, options, projectRoot }) {
|
|
|
293
330
|
};
|
|
294
331
|
}
|
|
295
332
|
async function transformAsset(file, context) {
|
|
296
|
-
const assetTransformer = require("./utils/assetTransformer");
|
|
297
333
|
const { assetRegistryPath, assetPlugins } = context.config;
|
|
298
334
|
const result = await assetTransformer.transform(
|
|
299
335
|
getBabelTransformArgs(file, context),
|
|
300
336
|
assetRegistryPath,
|
|
301
|
-
assetPlugins
|
|
337
|
+
assetPlugins,
|
|
302
338
|
);
|
|
303
339
|
const jsFile = {
|
|
304
340
|
...file,
|
|
@@ -313,9 +349,9 @@ async function transformJSWithBabel(file, context) {
|
|
|
313
349
|
const transformer = require(babelTransformerPath);
|
|
314
350
|
const transformResult = await transformer.transform(
|
|
315
351
|
getBabelTransformArgs(file, context, [
|
|
316
|
-
functionMapBabelPlugin,
|
|
317
|
-
importLocationsPlugin,
|
|
318
|
-
])
|
|
352
|
+
_metroSourceMap.functionMapBabelPlugin,
|
|
353
|
+
_importLocationsPlugin.importLocationsPlugin,
|
|
354
|
+
]),
|
|
319
355
|
);
|
|
320
356
|
const jsFile = {
|
|
321
357
|
...file,
|
|
@@ -338,8 +374,8 @@ async function transformJSON(file, { options, config, projectRoot }) {
|
|
|
338
374
|
config.globalPrefix,
|
|
339
375
|
Boolean(
|
|
340
376
|
options.customTransformOptions
|
|
341
|
-
?.unstable_staticHermesOptimizedRequire
|
|
342
|
-
)
|
|
377
|
+
?.unstable_staticHermesOptimizedRequire,
|
|
378
|
+
),
|
|
343
379
|
);
|
|
344
380
|
let map = [];
|
|
345
381
|
const minify =
|
|
@@ -353,7 +389,7 @@ async function transformJSON(file, { options, config, projectRoot }) {
|
|
|
353
389
|
file.filename,
|
|
354
390
|
code,
|
|
355
391
|
file.code,
|
|
356
|
-
map
|
|
392
|
+
map,
|
|
357
393
|
));
|
|
358
394
|
}
|
|
359
395
|
let jsType;
|
|
@@ -385,7 +421,7 @@ async function transformJSON(file, { options, config, projectRoot }) {
|
|
|
385
421
|
function getBabelTransformArgs(
|
|
386
422
|
file,
|
|
387
423
|
{ options, config, projectRoot },
|
|
388
|
-
plugins = []
|
|
424
|
+
plugins = [],
|
|
389
425
|
) {
|
|
390
426
|
const { inlineRequires: _, ...babelTransformerOptions } = options;
|
|
391
427
|
return {
|
|
@@ -403,82 +439,82 @@ function getBabelTransformArgs(
|
|
|
403
439
|
src: file.code,
|
|
404
440
|
};
|
|
405
441
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
)
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
if (filename.endsWith(".json")) {
|
|
436
|
-
const jsonFile = {
|
|
437
|
-
filename,
|
|
438
|
-
inputFileSize: data.length,
|
|
439
|
-
code: sourceCode,
|
|
440
|
-
type: options.type,
|
|
441
|
-
};
|
|
442
|
-
return await transformJSON(jsonFile, context);
|
|
443
|
-
}
|
|
444
|
-
if (options.type === "asset") {
|
|
445
|
-
const file = {
|
|
446
|
-
filename,
|
|
447
|
-
inputFileSize: data.length,
|
|
448
|
-
code: sourceCode,
|
|
449
|
-
type: options.type,
|
|
450
|
-
};
|
|
451
|
-
return await transformAsset(file, context);
|
|
442
|
+
const transform = async (config, projectRoot, filename, data, options) => {
|
|
443
|
+
const context = {
|
|
444
|
+
config,
|
|
445
|
+
projectRoot,
|
|
446
|
+
options,
|
|
447
|
+
};
|
|
448
|
+
const sourceCode = data.toString("utf8");
|
|
449
|
+
const reservedStrings = [];
|
|
450
|
+
if (
|
|
451
|
+
options.customTransformOptions?.unstable_staticHermesOptimizedRequire ==
|
|
452
|
+
true
|
|
453
|
+
) {
|
|
454
|
+
reservedStrings.push("_$$_METRO_MODULE_ID");
|
|
455
|
+
}
|
|
456
|
+
if (config.unstable_dependencyMapReservedName != null) {
|
|
457
|
+
reservedStrings.push(config.unstable_dependencyMapReservedName);
|
|
458
|
+
}
|
|
459
|
+
for (const reservedString of reservedStrings) {
|
|
460
|
+
const position = sourceCode.indexOf(reservedString);
|
|
461
|
+
if (position > -1) {
|
|
462
|
+
throw new SyntaxError(
|
|
463
|
+
"Source code contains the reserved string `" +
|
|
464
|
+
reservedString +
|
|
465
|
+
"` at character offset " +
|
|
466
|
+
position,
|
|
467
|
+
);
|
|
452
468
|
}
|
|
469
|
+
}
|
|
470
|
+
if (filename.endsWith(".json")) {
|
|
471
|
+
const jsonFile = {
|
|
472
|
+
filename,
|
|
473
|
+
inputFileSize: data.length,
|
|
474
|
+
code: sourceCode,
|
|
475
|
+
type: options.type,
|
|
476
|
+
};
|
|
477
|
+
return await transformJSON(jsonFile, context);
|
|
478
|
+
}
|
|
479
|
+
if (options.type === "asset") {
|
|
453
480
|
const file = {
|
|
454
481
|
filename,
|
|
455
482
|
inputFileSize: data.length,
|
|
456
483
|
code: sourceCode,
|
|
457
|
-
type: options.type
|
|
458
|
-
functionMap: null,
|
|
484
|
+
type: options.type,
|
|
459
485
|
};
|
|
460
|
-
return await
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
486
|
+
return await transformAsset(file, context);
|
|
487
|
+
}
|
|
488
|
+
const file = {
|
|
489
|
+
filename,
|
|
490
|
+
inputFileSize: data.length,
|
|
491
|
+
code: sourceCode,
|
|
492
|
+
type: options.type === "script" ? "js/script" : "js/module",
|
|
493
|
+
functionMap: null,
|
|
494
|
+
};
|
|
495
|
+
return await transformJSWithBabel(file, context);
|
|
496
|
+
};
|
|
497
|
+
exports.transform = transform;
|
|
498
|
+
const getCacheKey = (config) => {
|
|
499
|
+
const { babelTransformerPath, minifierPath, ...remainingConfig } = config;
|
|
500
|
+
const filesKey = (0, _metroCacheKey.getCacheKey)([
|
|
501
|
+
__filename,
|
|
502
|
+
require.resolve(babelTransformerPath),
|
|
503
|
+
require.resolve(minifierPath),
|
|
504
|
+
require.resolve("./utils/getMinifier"),
|
|
505
|
+
require.resolve("./utils/assetTransformer"),
|
|
506
|
+
require.resolve("metro/private/ModuleGraph/worker/generateImportNames"),
|
|
507
|
+
require.resolve("metro/private/ModuleGraph/worker/JsFileWrapping"),
|
|
508
|
+
..._metroTransformPlugins.default.getTransformPluginCacheKeyFiles(),
|
|
509
|
+
]);
|
|
510
|
+
const babelTransformer = require(babelTransformerPath);
|
|
511
|
+
return [
|
|
512
|
+
filesKey,
|
|
513
|
+
(0, _metroCache.stableHash)(remainingConfig).toString("hex"),
|
|
514
|
+
babelTransformer.getCacheKey ? babelTransformer.getCacheKey() : "",
|
|
515
|
+
].join("$");
|
|
481
516
|
};
|
|
517
|
+
exports.getCacheKey = getCacheKey;
|
|
482
518
|
function countLinesAndTerminateMap(code, map) {
|
|
483
519
|
const NEWLINE = /\r\n?|\n|\u2028|\u2029/g;
|
|
484
520
|
let lineCount = 1;
|
|
@@ -507,3 +543,7 @@ function countLinesAndTerminateMap(code, map) {
|
|
|
507
543
|
map: [...map],
|
|
508
544
|
};
|
|
509
545
|
}
|
|
546
|
+
var _default = (exports.default = {
|
|
547
|
+
getCacheKey,
|
|
548
|
+
transform,
|
|
549
|
+
});
|
package/src/index.js.flow
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {PluginEntry, Plugins} from '@babel/core';
|
|
15
13
|
import type {
|
|
16
14
|
BabelTransformer,
|
|
@@ -29,37 +27,38 @@ import type {
|
|
|
29
27
|
InlineRequiresPluginOptions,
|
|
30
28
|
} from 'metro-transform-plugins';
|
|
31
29
|
import type {TransformResultDependency} from 'metro/private/DeltaBundler';
|
|
32
|
-
import type {AllowOptionalDependencies} from 'metro/private/DeltaBundler/types
|
|
30
|
+
import type {AllowOptionalDependencies} from 'metro/private/DeltaBundler/types';
|
|
33
31
|
import type {
|
|
34
32
|
DependencyTransformer,
|
|
35
33
|
DynamicRequiresBehavior,
|
|
36
34
|
} from 'metro/private/ModuleGraph/worker/collectDependencies';
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
import * as assetTransformer from './utils/assetTransformer';
|
|
37
|
+
import getMinifier from './utils/getMinifier';
|
|
38
|
+
import {transformFromAstSync} from '@babel/core';
|
|
39
|
+
import generate from '@babel/generator';
|
|
40
|
+
import * as babylon from '@babel/parser';
|
|
41
|
+
import * as types from '@babel/types';
|
|
42
|
+
import {stableHash} from 'metro-cache';
|
|
43
|
+
import {getCacheKey as metroGetCacheKey} from 'metro-cache-key';
|
|
44
|
+
import {
|
|
46
45
|
fromRawMappings,
|
|
47
46
|
functionMapBabelPlugin,
|
|
48
47
|
toBabelSegments,
|
|
49
48
|
toSegmentTuple,
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} = require('metro/private/ModuleGraph/worker/collectDependencies');
|
|
56
|
-
const generateImportNames = require('metro/private/ModuleGraph/worker/generateImportNames');
|
|
57
|
-
const {
|
|
49
|
+
} from 'metro-source-map';
|
|
50
|
+
import metroTransformPlugins from 'metro-transform-plugins';
|
|
51
|
+
import collectDependencies from 'metro/private/ModuleGraph/worker/collectDependencies';
|
|
52
|
+
import generateImportNames from 'metro/private/ModuleGraph/worker/generateImportNames';
|
|
53
|
+
import {
|
|
58
54
|
importLocationsPlugin,
|
|
59
55
|
locToKey,
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
} from 'metro/private/ModuleGraph/worker/importLocationsPlugin';
|
|
57
|
+
import * as JsFileWrapping from 'metro/private/ModuleGraph/worker/JsFileWrapping';
|
|
58
|
+
import nullthrows from 'nullthrows';
|
|
59
|
+
|
|
60
|
+
const InternalInvalidRequireCallError =
|
|
61
|
+
collectDependencies.InvalidRequireCallError;
|
|
63
62
|
|
|
64
63
|
type MinifierConfig = $ReadOnly<{[string]: mixed, ...}>;
|
|
65
64
|
|
|
@@ -119,14 +118,12 @@ export type JsTransformOptions = $ReadOnly<{
|
|
|
119
118
|
customTransformOptions?: CustomTransformOptions,
|
|
120
119
|
dev: boolean,
|
|
121
120
|
experimentalImportSupport?: boolean,
|
|
122
|
-
hot: boolean,
|
|
123
121
|
inlinePlatform: boolean,
|
|
124
122
|
inlineRequires: boolean,
|
|
125
123
|
minify: boolean,
|
|
126
124
|
nonInlinedRequires?: $ReadOnlyArray<string>,
|
|
127
125
|
platform: ?string,
|
|
128
126
|
type: Type,
|
|
129
|
-
unstable_disableES6Transforms?: boolean,
|
|
130
127
|
unstable_memoizeInlineRequires?: boolean,
|
|
131
128
|
unstable_nonMemoizedInlineRequires?: $ReadOnlyArray<string>,
|
|
132
129
|
unstable_staticHermesOptimizedRequire?: boolean,
|
|
@@ -317,7 +314,7 @@ async function transformJS(
|
|
|
317
314
|
ignoredRequires: options.nonInlinedRequires,
|
|
318
315
|
inlineableCalls: [importDefault, importAll],
|
|
319
316
|
memoizeCalls:
|
|
320
|
-
// $FlowFixMe[incompatible-
|
|
317
|
+
// $FlowFixMe[incompatible-type] is this always (?boolean)?
|
|
321
318
|
options.customTransformOptions?.unstable_memoizeInlineRequires ??
|
|
322
319
|
options.unstable_memoizeInlineRequires,
|
|
323
320
|
nonMemoizedModules: options.unstable_nonMemoizedInlineRequires,
|
|
@@ -331,7 +328,7 @@ async function transformJS(
|
|
|
331
328
|
dev: options.dev,
|
|
332
329
|
inlinePlatform: options.inlinePlatform,
|
|
333
330
|
isWrapped: false,
|
|
334
|
-
// $FlowFixMe[incompatible-
|
|
331
|
+
// $FlowFixMe[incompatible-type] expects a string if inlinePlatform
|
|
335
332
|
platform: options.platform,
|
|
336
333
|
} as InlinePluginOptions,
|
|
337
334
|
]);
|
|
@@ -517,7 +514,6 @@ async function transformAsset(
|
|
|
517
514
|
file: AssetFile,
|
|
518
515
|
context: TransformationContext,
|
|
519
516
|
): Promise<TransformResponse> {
|
|
520
|
-
const assetTransformer = require('./utils/assetTransformer');
|
|
521
517
|
const {assetRegistryPath, assetPlugins} = context.config;
|
|
522
518
|
|
|
523
519
|
const result = await assetTransformer.transform(
|
|
@@ -653,98 +649,96 @@ function getBabelTransformArgs(
|
|
|
653
649
|
};
|
|
654
650
|
}
|
|
655
651
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
const sourceCode = data.toString('utf8');
|
|
670
|
-
|
|
671
|
-
const reservedStrings = [];
|
|
672
|
-
if (
|
|
673
|
-
options.customTransformOptions?.unstable_staticHermesOptimizedRequire ==
|
|
674
|
-
true
|
|
675
|
-
) {
|
|
676
|
-
reservedStrings.push('_$$_METRO_MODULE_ID');
|
|
677
|
-
}
|
|
678
|
-
if (config.unstable_dependencyMapReservedName != null) {
|
|
679
|
-
reservedStrings.push(config.unstable_dependencyMapReservedName);
|
|
680
|
-
}
|
|
681
|
-
for (const reservedString of reservedStrings) {
|
|
682
|
-
const position = sourceCode.indexOf(reservedString);
|
|
683
|
-
if (position > -1) {
|
|
684
|
-
throw new SyntaxError(
|
|
685
|
-
'Source code contains the reserved string `' +
|
|
686
|
-
reservedString +
|
|
687
|
-
'` at character offset ' +
|
|
688
|
-
position,
|
|
689
|
-
);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
if (filename.endsWith('.json')) {
|
|
694
|
-
const jsonFile: JSONFile = {
|
|
695
|
-
filename,
|
|
696
|
-
inputFileSize: data.length,
|
|
697
|
-
code: sourceCode,
|
|
698
|
-
type: options.type,
|
|
699
|
-
};
|
|
652
|
+
export const transform = async (
|
|
653
|
+
config: JsTransformerConfig,
|
|
654
|
+
projectRoot: string,
|
|
655
|
+
filename: string,
|
|
656
|
+
data: Buffer,
|
|
657
|
+
options: JsTransformOptions,
|
|
658
|
+
): Promise<TransformResponse> => {
|
|
659
|
+
const context: TransformationContext = {
|
|
660
|
+
config,
|
|
661
|
+
projectRoot,
|
|
662
|
+
options,
|
|
663
|
+
};
|
|
664
|
+
const sourceCode = data.toString('utf8');
|
|
700
665
|
|
|
701
|
-
|
|
666
|
+
const reservedStrings = [];
|
|
667
|
+
if (
|
|
668
|
+
options.customTransformOptions?.unstable_staticHermesOptimizedRequire ==
|
|
669
|
+
true
|
|
670
|
+
) {
|
|
671
|
+
reservedStrings.push('_$$_METRO_MODULE_ID');
|
|
672
|
+
}
|
|
673
|
+
if (config.unstable_dependencyMapReservedName != null) {
|
|
674
|
+
reservedStrings.push(config.unstable_dependencyMapReservedName);
|
|
675
|
+
}
|
|
676
|
+
for (const reservedString of reservedStrings) {
|
|
677
|
+
const position = sourceCode.indexOf(reservedString);
|
|
678
|
+
if (position > -1) {
|
|
679
|
+
throw new SyntaxError(
|
|
680
|
+
'Source code contains the reserved string `' +
|
|
681
|
+
reservedString +
|
|
682
|
+
'` at character offset ' +
|
|
683
|
+
position,
|
|
684
|
+
);
|
|
702
685
|
}
|
|
686
|
+
}
|
|
703
687
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
688
|
+
if (filename.endsWith('.json')) {
|
|
689
|
+
const jsonFile: JSONFile = {
|
|
690
|
+
filename,
|
|
691
|
+
inputFileSize: data.length,
|
|
692
|
+
code: sourceCode,
|
|
693
|
+
type: options.type,
|
|
694
|
+
};
|
|
711
695
|
|
|
712
|
-
|
|
713
|
-
|
|
696
|
+
return await transformJSON(jsonFile, context);
|
|
697
|
+
}
|
|
714
698
|
|
|
715
|
-
|
|
699
|
+
if (options.type === 'asset') {
|
|
700
|
+
const file: AssetFile = {
|
|
716
701
|
filename,
|
|
717
702
|
inputFileSize: data.length,
|
|
718
703
|
code: sourceCode,
|
|
719
|
-
type: options.type
|
|
720
|
-
functionMap: null,
|
|
704
|
+
type: options.type,
|
|
721
705
|
};
|
|
722
706
|
|
|
723
|
-
return await
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
getCacheKey: (config: JsTransformerConfig): string => {
|
|
727
|
-
const {babelTransformerPath, minifierPath, ...remainingConfig} = config;
|
|
728
|
-
|
|
729
|
-
const filesKey = getCacheKey([
|
|
730
|
-
__filename,
|
|
731
|
-
require.resolve(babelTransformerPath),
|
|
732
|
-
require.resolve(minifierPath),
|
|
733
|
-
require.resolve('./utils/getMinifier'),
|
|
734
|
-
require.resolve('./utils/assetTransformer'),
|
|
735
|
-
require.resolve('metro/private/ModuleGraph/worker/generateImportNames'),
|
|
736
|
-
require.resolve('metro/private/ModuleGraph/worker/JsFileWrapping'),
|
|
737
|
-
...metroTransformPlugins.getTransformPluginCacheKeyFiles(),
|
|
738
|
-
]);
|
|
707
|
+
return await transformAsset(file, context);
|
|
708
|
+
}
|
|
739
709
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
710
|
+
const file: JSFile = {
|
|
711
|
+
filename,
|
|
712
|
+
inputFileSize: data.length,
|
|
713
|
+
code: sourceCode,
|
|
714
|
+
type: options.type === 'script' ? 'js/script' : 'js/module',
|
|
715
|
+
functionMap: null,
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
return await transformJSWithBabel(file, context);
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
export const getCacheKey = (config: JsTransformerConfig): string => {
|
|
722
|
+
const {babelTransformerPath, minifierPath, ...remainingConfig} = config;
|
|
723
|
+
|
|
724
|
+
const filesKey = metroGetCacheKey([
|
|
725
|
+
__filename,
|
|
726
|
+
require.resolve(babelTransformerPath),
|
|
727
|
+
require.resolve(minifierPath),
|
|
728
|
+
require.resolve('./utils/getMinifier'),
|
|
729
|
+
require.resolve('./utils/assetTransformer'),
|
|
730
|
+
require.resolve('metro/private/ModuleGraph/worker/generateImportNames'),
|
|
731
|
+
require.resolve('metro/private/ModuleGraph/worker/JsFileWrapping'),
|
|
732
|
+
...metroTransformPlugins.getTransformPluginCacheKeyFiles(),
|
|
733
|
+
]);
|
|
734
|
+
|
|
735
|
+
// $FlowFixMe[unsupported-syntax]
|
|
736
|
+
const babelTransformer = require(babelTransformerPath);
|
|
737
|
+
return [
|
|
738
|
+
filesKey,
|
|
739
|
+
stableHash(remainingConfig).toString('hex'),
|
|
740
|
+
babelTransformer.getCacheKey ? babelTransformer.getCacheKey() : '',
|
|
741
|
+
].join('$');
|
|
748
742
|
};
|
|
749
743
|
|
|
750
744
|
function countLinesAndTerminateMap(
|
|
@@ -785,3 +779,14 @@ function countLinesAndTerminateMap(
|
|
|
785
779
|
}
|
|
786
780
|
return {lineCount, map: [...map]};
|
|
787
781
|
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Backwards-compatibility with CommonJS consumers using interopRequireDefault.
|
|
785
|
+
* Do not add to this list.
|
|
786
|
+
*
|
|
787
|
+
* @deprecated Default import from 'metro-transform-worker' is deprecated, use named exports.
|
|
788
|
+
*/
|
|
789
|
+
export default {
|
|
790
|
+
getCacheKey,
|
|
791
|
+
transform,
|
|
792
|
+
};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.transform = transform;
|
|
7
|
+
var _Assets = require("metro/private/Assets");
|
|
8
|
+
var _util = require("metro/private/Bundler/util");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
function _interopRequireDefault(e) {
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
12
|
+
}
|
|
6
13
|
async function transform(
|
|
7
14
|
{ filename, options, src },
|
|
8
15
|
assetRegistryPath,
|
|
9
|
-
assetDataPlugins
|
|
16
|
+
assetDataPlugins,
|
|
10
17
|
) {
|
|
11
18
|
options = options || {
|
|
12
19
|
platform: "",
|
|
@@ -14,18 +21,15 @@ async function transform(
|
|
|
14
21
|
inlineRequires: false,
|
|
15
22
|
minify: false,
|
|
16
23
|
};
|
|
17
|
-
const absolutePath =
|
|
18
|
-
const data = await getAssetData(
|
|
24
|
+
const absolutePath = _path.default.resolve(options.projectRoot, filename);
|
|
25
|
+
const data = await (0, _Assets.getAssetData)(
|
|
19
26
|
absolutePath,
|
|
20
27
|
filename,
|
|
21
28
|
assetDataPlugins,
|
|
22
29
|
options.platform,
|
|
23
|
-
options.publicPath
|
|
30
|
+
options.publicPath,
|
|
24
31
|
);
|
|
25
32
|
return {
|
|
26
|
-
ast: generateAssetCodeFileAst(assetRegistryPath, data),
|
|
33
|
+
ast: (0, _util.generateAssetCodeFileAst)(assetRegistryPath, data),
|
|
27
34
|
};
|
|
28
35
|
}
|
|
29
|
-
module.exports = {
|
|
30
|
-
transform,
|
|
31
|
-
};
|
|
@@ -9,16 +9,14 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {File} from '@babel/types';
|
|
15
13
|
import type {BabelTransformerArgs} from 'metro-babel-transformer';
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
import {getAssetData} from 'metro/private/Assets';
|
|
16
|
+
import {generateAssetCodeFileAst} from 'metro/private/Bundler/util';
|
|
17
|
+
import path from 'path';
|
|
20
18
|
|
|
21
|
-
async function transform(
|
|
19
|
+
export async function transform(
|
|
22
20
|
{filename, options, src}: BabelTransformerArgs,
|
|
23
21
|
assetRegistryPath: string,
|
|
24
22
|
assetDataPlugins: $ReadOnlyArray<string>,
|
|
@@ -44,7 +42,3 @@ async function transform(
|
|
|
44
42
|
ast: generateAssetCodeFileAst(assetRegistryPath, data),
|
|
45
43
|
};
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
module.exports = {
|
|
49
|
-
transform,
|
|
50
|
-
};
|
package/src/utils/getMinifier.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = getMinifier;
|
|
3
7
|
function getMinifier(minifierPath) {
|
|
4
8
|
try {
|
|
5
9
|
return require(minifierPath);
|
|
@@ -8,8 +12,7 @@ function getMinifier(minifierPath) {
|
|
|
8
12
|
'A problem occurred while trying to fetch the minifier. Path: "' +
|
|
9
13
|
minifierPath +
|
|
10
14
|
'", error message: ' +
|
|
11
|
-
e.message
|
|
15
|
+
e.message,
|
|
12
16
|
);
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
|
-
module.exports = getMinifier;
|
|
@@ -9,16 +9,14 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {Minifier} from '../index.js';
|
|
15
13
|
|
|
16
|
-
function getMinifier(minifierPath: string): Minifier {
|
|
14
|
+
export default function getMinifier(minifierPath: string): Minifier {
|
|
17
15
|
// Note: minifierPath should be an absolute path OR a module name here!
|
|
18
16
|
// The options allow relative paths but they HAVE to be normalized at
|
|
19
17
|
// any entry point that accepts them...
|
|
20
18
|
try {
|
|
21
|
-
// $FlowFixMe TODO t0 cannot do require with literal
|
|
19
|
+
// $FlowFixMe[unsupported-syntax] TODO t0 cannot do require with literal
|
|
22
20
|
return require(minifierPath);
|
|
23
21
|
} catch (e) {
|
|
24
22
|
throw new Error(
|
|
@@ -29,5 +27,3 @@ function getMinifier(minifierPath: string): Minifier {
|
|
|
29
27
|
);
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
module.exports = getMinifier;
|