metro-transform-worker 0.70.2 → 0.71.1
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 +11 -11
- package/src/index.js +1 -1
- package/src/index.js.flow +11 -10
- package/src/__mocks__/index.js +0 -13
- package/src.real/__mocks__/index.js +0 -14
- package/src.real/__tests__/__snapshots__/index-test.js.snap +0 -329
- package/src.real/__tests__/index-test.js +0 -647
- package/src.real/index.js +0 -754
- package/src.real/utils/assetTransformer.js +0 -49
- package/src.real/utils/getMinifier.js +0 -32
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
import type {File} from '@babel/types';
|
|
14
|
-
import type {BabelTransformerArgs} from 'metro-babel-transformer';
|
|
15
|
-
|
|
16
|
-
const {getAssetData} = require('metro/src/Assets');
|
|
17
|
-
const {generateAssetCodeFileAst} = require('metro/src/Bundler/util');
|
|
18
|
-
const path = require('path');
|
|
19
|
-
|
|
20
|
-
async function transform(
|
|
21
|
-
{filename, options, src}: BabelTransformerArgs,
|
|
22
|
-
assetRegistryPath: string,
|
|
23
|
-
assetDataPlugins: $ReadOnlyArray<string>,
|
|
24
|
-
): Promise<{ast: File, ...}> {
|
|
25
|
-
options = options || {
|
|
26
|
-
platform: '',
|
|
27
|
-
projectRoot: '',
|
|
28
|
-
inlineRequires: false,
|
|
29
|
-
minify: false,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const absolutePath = path.resolve(options.projectRoot, filename);
|
|
33
|
-
|
|
34
|
-
const data = await getAssetData(
|
|
35
|
-
absolutePath,
|
|
36
|
-
filename,
|
|
37
|
-
assetDataPlugins,
|
|
38
|
-
options.platform,
|
|
39
|
-
options.publicPath,
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
ast: generateAssetCodeFileAst(assetRegistryPath, data),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
module.exports = {
|
|
48
|
-
transform,
|
|
49
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
import type {Minifier} from '../index.js';
|
|
14
|
-
|
|
15
|
-
function getMinifier(minifierPath: string): Minifier {
|
|
16
|
-
// Note: minifierPath should be an absolute path OR a module name here!
|
|
17
|
-
// The options allow relative paths but they HAVE to be normalized at
|
|
18
|
-
// any entry point that accepts them...
|
|
19
|
-
try {
|
|
20
|
-
// $FlowFixMe TODO t0 cannot do require with literal
|
|
21
|
-
return require(minifierPath);
|
|
22
|
-
} catch (e) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
'A problem occurred while trying to fetch the minifier. Path: "' +
|
|
25
|
-
minifierPath +
|
|
26
|
-
'", error message: ' +
|
|
27
|
-
e.message,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = getMinifier;
|