@expo/metro-config 0.17.2 → 0.17.4

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.
Files changed (85) hide show
  1. package/build/ExpoMetroConfig.js +239 -366
  2. package/build/ExpoMetroConfig.js.map +1 -1
  3. package/build/babel-core.js +6 -23
  4. package/build/babel-core.js.map +1 -1
  5. package/build/babel-transformer.js +117 -162
  6. package/build/babel-transformer.js.map +1 -1
  7. package/build/customizeFrame.js +84 -78
  8. package/build/customizeFrame.js.map +1 -1
  9. package/build/env.js +23 -37
  10. package/build/env.js.map +1 -1
  11. package/build/file-store.js +13 -21
  12. package/build/file-store.js.map +1 -1
  13. package/build/getModulesPaths.js +31 -48
  14. package/build/getModulesPaths.js.map +1 -1
  15. package/build/getWatchFolders.js +70 -98
  16. package/build/getWatchFolders.js.map +1 -1
  17. package/build/loadBabelConfig.js +30 -49
  18. package/build/loadBabelConfig.js.map +1 -1
  19. package/build/rewriteRequestUrl.js +82 -142
  20. package/build/rewriteRequestUrl.js.map +1 -1
  21. package/build/serializer/debugId.js +23 -22
  22. package/build/serializer/debugId.js.map +1 -1
  23. package/build/serializer/environmentVariableSerializerPlugin.js +90 -101
  24. package/build/serializer/environmentVariableSerializerPlugin.js.map +1 -1
  25. package/build/serializer/exportHermes.js +96 -133
  26. package/build/serializer/exportHermes.js.map +1 -1
  27. package/build/serializer/exportPath.js +18 -35
  28. package/build/serializer/exportPath.js.map +1 -1
  29. package/build/serializer/fork/baseJSBundle.js +124 -147
  30. package/build/serializer/fork/baseJSBundle.js.map +1 -1
  31. package/build/serializer/fork/js.js +81 -116
  32. package/build/serializer/fork/js.js.map +1 -1
  33. package/build/serializer/fork/processModules.js +22 -36
  34. package/build/serializer/fork/processModules.js.map +1 -1
  35. package/build/serializer/getCssDeps.js +64 -95
  36. package/build/serializer/getCssDeps.js.map +1 -1
  37. package/build/serializer/jsOutput.js +6 -16
  38. package/build/serializer/jsOutput.js.map +1 -1
  39. package/build/serializer/serializeChunks.js +406 -483
  40. package/build/serializer/serializeChunks.js.map +1 -1
  41. package/build/serializer/serializerAssets.js +1 -0
  42. package/build/serializer/serializerAssets.js.map +1 -1
  43. package/build/serializer/withExpoSerializers.js +165 -236
  44. package/build/serializer/withExpoSerializers.js.map +1 -1
  45. package/build/transform-worker/asset-transformer.js +21 -44
  46. package/build/transform-worker/asset-transformer.js.map +1 -1
  47. package/build/transform-worker/css-modules.js +57 -84
  48. package/build/transform-worker/css-modules.js.map +1 -1
  49. package/build/transform-worker/css.js +21 -20
  50. package/build/transform-worker/css.js.map +1 -1
  51. package/build/transform-worker/getAssets.js +38 -75
  52. package/build/transform-worker/getAssets.js.map +1 -1
  53. package/build/transform-worker/metro-transform-worker.js +384 -489
  54. package/build/transform-worker/metro-transform-worker.js.map +1 -1
  55. package/build/transform-worker/postcss.js +176 -233
  56. package/build/transform-worker/postcss.js.map +1 -1
  57. package/build/transform-worker/sass.js +30 -38
  58. package/build/transform-worker/sass.js.map +1 -1
  59. package/build/transform-worker/transform-worker.js +156 -188
  60. package/build/transform-worker/transform-worker.js.map +1 -1
  61. package/build/transform-worker/utils/require.js +30 -28
  62. package/build/transform-worker/utils/require.js.map +1 -1
  63. package/build/transformSync.js +40 -28
  64. package/build/transformSync.js.map +1 -1
  65. package/build/transformer/createExoticTransformer.js +96 -129
  66. package/build/transformer/createExoticTransformer.js.map +1 -1
  67. package/build/transformer/createMatcher.js +37 -46
  68. package/build/transformer/createMatcher.js.map +1 -1
  69. package/build/transformer/createMultiRuleTransformer.js +170 -240
  70. package/build/transformer/createMultiRuleTransformer.js.map +1 -1
  71. package/build/transformer/generateFunctionMap.js +20 -23
  72. package/build/transformer/generateFunctionMap.js.map +1 -1
  73. package/build/transformer/getBabelConfig.js +94 -127
  74. package/build/transformer/getBabelConfig.js.map +1 -1
  75. package/build/transformer/getCacheKey.js +17 -31
  76. package/build/transformer/getCacheKey.js.map +1 -1
  77. package/build/transformer/index.js +11 -62
  78. package/build/transformer/index.js.map +1 -1
  79. package/build/transformer/metro-expo-exotic-babel-transformer.js +3 -12
  80. package/build/transformer/metro-expo-exotic-babel-transformer.js.map +1 -1
  81. package/build/traveling/metro-config.js +12 -19
  82. package/build/traveling/metro-config.js.map +1 -1
  83. package/build/utils/hash.js +8 -14
  84. package/build/utils/hash.js.map +1 -1
  85. package/package.json +6 -6
@@ -1,42 +1,4 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getJsOutput = getJsOutput;
7
- exports.getModuleParams = getModuleParams;
8
- exports.isJsModule = isJsModule;
9
- exports.isJsOutput = isJsOutput;
10
- exports.wrapModule = wrapModule;
11
- function _assert() {
12
- const data = _interopRequireDefault(require("assert"));
13
- _assert = function () {
14
- return data;
15
- };
16
- return data;
17
- }
18
- function _jscSafeUrl() {
19
- const data = _interopRequireDefault(require("jsc-safe-url"));
20
- _jscSafeUrl = function () {
21
- return data;
22
- };
23
- return data;
24
- }
25
- function _metroTransformPlugins() {
26
- const data = require("metro-transform-plugins");
27
- _metroTransformPlugins = function () {
28
- return data;
29
- };
30
- return data;
31
- }
32
- function _path() {
33
- const data = _interopRequireDefault(require("path"));
34
- _path = function () {
35
- return data;
36
- };
37
- return data;
38
- }
39
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
2
  /**
41
3
  * Copyright © 2022 650 Industries.
42
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -47,94 +9,97 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
47
9
  * Fork of the metro helper, but with bundle splitting support.
48
10
  * https://github.com/facebook/metro/blob/bbdd7d7c5e6e0feb50a9967ffae1f723c1d7c4e8/packages/metro/src/DeltaBundler/Serializers/helpers/js.js#L1
49
11
  */
50
-
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.isJsOutput = exports.isJsModule = exports.getJsOutput = exports.getModuleParams = exports.wrapModule = void 0;
17
+ const assert_1 = __importDefault(require("assert"));
18
+ const jsc_safe_url_1 = __importDefault(require("jsc-safe-url"));
19
+ const metro_transform_plugins_1 = require("metro-transform-plugins");
20
+ const path_1 = __importDefault(require("path"));
51
21
  function wrapModule(module, options) {
52
- const output = getJsOutput(module);
53
- if (output.type.startsWith('js/script')) {
54
- return {
55
- src: output.data.code,
56
- paths: {}
57
- };
58
- }
59
- const {
60
- params,
61
- paths
62
- } = getModuleParams(module, options);
63
- let src = output.data.code;
64
- if (!options.skipWrapping) {
65
- src = (0, _metroTransformPlugins().addParamsToDefineCall)(output.data.code, ...params);
66
- }
67
- return {
68
- src,
69
- paths
70
- };
22
+ const output = getJsOutput(module);
23
+ if (output.type.startsWith('js/script')) {
24
+ return { src: output.data.code, paths: {} };
25
+ }
26
+ const { params, paths } = getModuleParams(module, options);
27
+ let src = output.data.code;
28
+ if (!options.skipWrapping) {
29
+ src = (0, metro_transform_plugins_1.addParamsToDefineCall)(output.data.code, ...params);
30
+ }
31
+ return { src, paths };
71
32
  }
33
+ exports.wrapModule = wrapModule;
72
34
  function getModuleParams(module, options) {
73
- const moduleId = options.createModuleId(module.path);
74
- const paths = {};
75
- let hasPaths = false;
76
- const dependencyMapArray = Array.from(module.dependencies.values()).map(dependency => {
77
- const id = options.createModuleId(dependency.absolutePath);
78
- if (
79
- // NOTE(EvanBacon): Disabled this to ensure that paths are provided even when the entire bundle
80
- // is created. This is required for production bundle splitting.
81
- // options.includeAsyncPaths &&
82
-
83
- dependency.data.data.asyncType != null) {
84
- if (options.includeAsyncPaths) {
85
- if (options.sourceUrl) {
86
- hasPaths = true;
87
- // TODO: Only include path if the target is not in the bundle
88
-
89
- // Construct a server-relative URL for the split bundle, propagating
90
- // most parameters from the main bundle's URL.
91
-
92
- const {
93
- searchParams
94
- } = new URL(_jscSafeUrl().default.toNormalUrl(options.sourceUrl));
95
- searchParams.set('modulesOnly', 'true');
96
- searchParams.set('runModule', 'false');
97
- const bundlePath = _path().default.relative(options.serverRoot, dependency.absolutePath);
98
- paths[id] = '/' + _path().default.join(_path().default.dirname(bundlePath),
99
- // Strip the file extension
100
- _path().default.basename(bundlePath, _path().default.extname(bundlePath))) + '.bundle?' + searchParams.toString();
35
+ const moduleId = options.createModuleId(module.path);
36
+ const paths = {};
37
+ let hasPaths = false;
38
+ const dependencyMapArray = Array.from(module.dependencies.values()).map((dependency) => {
39
+ const id = options.createModuleId(dependency.absolutePath);
40
+ if (
41
+ // NOTE(EvanBacon): Disabled this to ensure that paths are provided even when the entire bundle
42
+ // is created. This is required for production bundle splitting.
43
+ // options.includeAsyncPaths &&
44
+ dependency.data.data.asyncType != null) {
45
+ if (options.includeAsyncPaths) {
46
+ if (options.sourceUrl) {
47
+ hasPaths = true;
48
+ // TODO: Only include path if the target is not in the bundle
49
+ // Construct a server-relative URL for the split bundle, propagating
50
+ // most parameters from the main bundle's URL.
51
+ const { searchParams } = new URL(jsc_safe_url_1.default.toNormalUrl(options.sourceUrl));
52
+ searchParams.set('modulesOnly', 'true');
53
+ searchParams.set('runModule', 'false');
54
+ const bundlePath = path_1.default.relative(options.serverRoot, dependency.absolutePath);
55
+ paths[id] =
56
+ '/' +
57
+ path_1.default.join(path_1.default.dirname(bundlePath),
58
+ // Strip the file extension
59
+ path_1.default.basename(bundlePath, path_1.default.extname(bundlePath))) +
60
+ '.bundle?' +
61
+ searchParams.toString();
62
+ }
63
+ }
64
+ else if (options.splitChunks && options.computedAsyncModulePaths != null) {
65
+ hasPaths = true;
66
+ // A template string that we'll match and replace later when we know the content hash for a given path.
67
+ paths[id] = options.computedAsyncModulePaths[dependency.absolutePath];
68
+ }
101
69
  }
102
- } else if (options.splitChunks && options.computedAsyncModulePaths != null) {
103
- hasPaths = true;
104
- // A template string that we'll match and replace later when we know the content hash for a given path.
105
- paths[id] = options.computedAsyncModulePaths[dependency.absolutePath];
106
- }
70
+ return id;
71
+ });
72
+ const params = [
73
+ moduleId,
74
+ hasPaths
75
+ ? {
76
+ ...dependencyMapArray,
77
+ paths,
78
+ }
79
+ : dependencyMapArray,
80
+ ];
81
+ if (options.dev) {
82
+ // Add the relative path of the module to make debugging easier.
83
+ // This is mapped to `module.verboseName` in `require.js`.
84
+ params.push(path_1.default.relative(options.projectRoot, module.path));
107
85
  }
108
- return id;
109
- });
110
- const params = [moduleId, hasPaths ? {
111
- ...dependencyMapArray,
112
- paths
113
- } : dependencyMapArray];
114
- if (options.dev) {
115
- // Add the relative path of the module to make debugging easier.
116
- // This is mapped to `module.verboseName` in `require.js`.
117
- params.push(_path().default.relative(options.projectRoot, module.path));
118
- }
119
- return {
120
- params,
121
- paths
122
- };
86
+ return { params, paths };
123
87
  }
88
+ exports.getModuleParams = getModuleParams;
124
89
  function getJsOutput(module) {
125
- var _module$path, _module$path2;
126
- const jsModules = module.output.filter(({
127
- type
128
- }) => type.startsWith('js/'));
129
- (0, _assert().default)(jsModules.length === 1, `Modules must have exactly one JS output, but ${(_module$path = module.path) !== null && _module$path !== void 0 ? _module$path : 'unknown module'} has ${jsModules.length} JS outputs.`);
130
- const jsOutput = jsModules[0];
131
- (0, _assert().default)(Number.isFinite(jsOutput.data.lineCount), `JS output must populate lineCount, but ${(_module$path2 = module.path) !== null && _module$path2 !== void 0 ? _module$path2 : 'unknown module'} has ${jsOutput.type} output with lineCount '${jsOutput.data.lineCount}'`);
132
- return jsOutput;
90
+ const jsModules = module.output.filter(({ type }) => type.startsWith('js/'));
91
+ (0, assert_1.default)(jsModules.length === 1, `Modules must have exactly one JS output, but ${module.path ?? 'unknown module'} has ${jsModules.length} JS outputs.`);
92
+ const jsOutput = jsModules[0];
93
+ (0, assert_1.default)(Number.isFinite(jsOutput.data.lineCount), `JS output must populate lineCount, but ${module.path ?? 'unknown module'} has ${jsOutput.type} output with lineCount '${jsOutput.data.lineCount}'`);
94
+ return jsOutput;
133
95
  }
96
+ exports.getJsOutput = getJsOutput;
134
97
  function isJsModule(module) {
135
- return module.output.filter(isJsOutput).length > 0;
98
+ return module.output.filter(isJsOutput).length > 0;
136
99
  }
100
+ exports.isJsModule = isJsModule;
137
101
  function isJsOutput(output) {
138
- return output.type.startsWith('js/');
102
+ return output.type.startsWith('js/');
139
103
  }
104
+ exports.isJsOutput = isJsOutput;
140
105
  //# sourceMappingURL=js.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"js.js","names":["_assert","data","_interopRequireDefault","require","_jscSafeUrl","_metroTransformPlugins","_path","obj","__esModule","default","wrapModule","module","options","output","getJsOutput","type","startsWith","src","code","paths","params","getModuleParams","skipWrapping","addParamsToDefineCall","moduleId","createModuleId","path","hasPaths","dependencyMapArray","Array","from","dependencies","values","map","dependency","id","absolutePath","asyncType","includeAsyncPaths","sourceUrl","searchParams","URL","jscSafeUrl","toNormalUrl","set","bundlePath","relative","serverRoot","join","dirname","basename","extname","toString","splitChunks","computedAsyncModulePaths","dev","push","projectRoot","_module$path","_module$path2","jsModules","filter","assert","length","jsOutput","Number","isFinite","lineCount","isJsModule","isJsOutput"],"sources":["../../../src/serializer/fork/js.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\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 *\n * Fork of the metro helper, but with bundle splitting support.\n * https://github.com/facebook/metro/blob/bbdd7d7c5e6e0feb50a9967ffae1f723c1d7c4e8/packages/metro/src/DeltaBundler/Serializers/helpers/js.js#L1\n */\n\nimport assert from 'assert';\nimport jscSafeUrl from 'jsc-safe-url';\nimport type { MixedOutput, Module } from 'metro';\nimport { addParamsToDefineCall } from 'metro-transform-plugins';\nimport type { JsOutput } from 'metro-transform-worker';\nimport path from 'path';\n\nexport type Options = {\n createModuleId: (module: string) => number | string;\n dev: boolean;\n includeAsyncPaths: boolean;\n projectRoot: string;\n serverRoot: string;\n sourceUrl: string | undefined;\n splitChunks: boolean;\n skipWrapping: boolean;\n computedAsyncModulePaths: Record<string, string> | null;\n};\n\nexport function wrapModule(\n module: Module,\n options: Options\n): { src: string; paths: Record<string, string> } {\n const output = getJsOutput(module);\n\n if (output.type.startsWith('js/script')) {\n return { src: output.data.code, paths: {} };\n }\n\n const { params, paths } = getModuleParams(module, options);\n let src = output.data.code;\n if (!options.skipWrapping) {\n src = addParamsToDefineCall(output.data.code, ...params);\n }\n\n return { src, paths };\n}\n\nexport function getModuleParams(\n module: Module,\n options: Pick<\n Options,\n | 'createModuleId'\n | 'sourceUrl'\n | 'includeAsyncPaths'\n | 'serverRoot'\n | 'splitChunks'\n | 'dev'\n | 'projectRoot'\n | 'computedAsyncModulePaths'\n >\n): { params: any[]; paths: Record<string, string> } {\n const moduleId = options.createModuleId(module.path);\n\n const paths: { [moduleID: number | string]: any } = {};\n let hasPaths = false;\n const dependencyMapArray = Array.from(module.dependencies.values()).map((dependency) => {\n const id = options.createModuleId(dependency.absolutePath);\n if (\n // NOTE(EvanBacon): Disabled this to ensure that paths are provided even when the entire bundle\n // is created. This is required for production bundle splitting.\n // options.includeAsyncPaths &&\n\n dependency.data.data.asyncType != null\n ) {\n if (options.includeAsyncPaths) {\n if (options.sourceUrl) {\n hasPaths = true;\n // TODO: Only include path if the target is not in the bundle\n\n // Construct a server-relative URL for the split bundle, propagating\n // most parameters from the main bundle's URL.\n\n const { searchParams } = new URL(jscSafeUrl.toNormalUrl(options.sourceUrl));\n searchParams.set('modulesOnly', 'true');\n searchParams.set('runModule', 'false');\n\n const bundlePath = path.relative(options.serverRoot, dependency.absolutePath);\n paths[id] =\n '/' +\n path.join(\n path.dirname(bundlePath),\n // Strip the file extension\n path.basename(bundlePath, path.extname(bundlePath))\n ) +\n '.bundle?' +\n searchParams.toString();\n }\n } else if (options.splitChunks && options.computedAsyncModulePaths != null) {\n hasPaths = true;\n // A template string that we'll match and replace later when we know the content hash for a given path.\n paths[id] = options.computedAsyncModulePaths[dependency.absolutePath];\n }\n }\n return id;\n });\n\n const params = [\n moduleId,\n hasPaths\n ? {\n ...dependencyMapArray,\n paths,\n }\n : dependencyMapArray,\n ];\n\n if (options.dev) {\n // Add the relative path of the module to make debugging easier.\n // This is mapped to `module.verboseName` in `require.js`.\n params.push(path.relative(options.projectRoot, module.path));\n }\n\n return { params, paths };\n}\n\nexport function getJsOutput(module: {\n output: readonly MixedOutput[];\n path?: string;\n // ...\n}): JsOutput {\n const jsModules = module.output.filter(({ type }) => type.startsWith('js/'));\n\n assert(\n jsModules.length === 1,\n `Modules must have exactly one JS output, but ${module.path ?? 'unknown module'} has ${\n jsModules.length\n } JS outputs.`\n );\n\n const jsOutput: JsOutput = jsModules[0] as unknown as any;\n\n assert(\n Number.isFinite(jsOutput.data.lineCount),\n `JS output must populate lineCount, but ${module.path ?? 'unknown module'} has ${\n jsOutput.type\n } output with lineCount '${jsOutput.data.lineCount}'`\n );\n\n return jsOutput;\n}\n\nexport function isJsModule(module: Module): boolean {\n return module.output.filter(isJsOutput).length > 0;\n}\n\nexport function isJsOutput(output: MixedOutput): output is MixedOutput {\n return output.type.startsWith('js/');\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,uBAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,sBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;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D,gCAEC"}
@@ -1,16 +1,4 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.processModules = processModules;
7
- function _js() {
8
- const data = require("./js");
9
- _js = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
2
  /**
15
3
  * Copyright © 2022 650 Industries.
16
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -18,29 +6,27 @@ function _js() {
18
6
  * This source code is licensed under the MIT license found in the
19
7
  * LICENSE file in the root directory of this source tree.
20
8
  */
21
-
22
- function processModules(modules, {
23
- filter = () => true,
24
- createModuleId,
25
- dev,
26
- includeAsyncPaths,
27
- projectRoot,
28
- serverRoot,
29
- sourceUrl,
30
- splitChunks,
31
- skipWrapping,
32
- computedAsyncModulePaths
33
- }) {
34
- return [...modules].filter(_js().isJsModule).filter(filter).map(module => [module, (0, _js().wrapModule)(module, {
35
- splitChunks,
36
- createModuleId,
37
- dev,
38
- includeAsyncPaths,
39
- projectRoot,
40
- serverRoot,
41
- sourceUrl,
42
- skipWrapping,
43
- computedAsyncModulePaths
44
- })]);
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.processModules = void 0;
11
+ const js_1 = require("./js");
12
+ function processModules(modules, { filter = () => true, createModuleId, dev, includeAsyncPaths, projectRoot, serverRoot, sourceUrl, splitChunks, skipWrapping, computedAsyncModulePaths, }) {
13
+ return [...modules]
14
+ .filter(js_1.isJsModule)
15
+ .filter(filter)
16
+ .map((module) => [
17
+ module,
18
+ (0, js_1.wrapModule)(module, {
19
+ splitChunks,
20
+ createModuleId,
21
+ dev,
22
+ includeAsyncPaths,
23
+ projectRoot,
24
+ serverRoot,
25
+ sourceUrl,
26
+ skipWrapping,
27
+ computedAsyncModulePaths,
28
+ }),
29
+ ]);
45
30
  }
31
+ exports.processModules = processModules;
46
32
  //# sourceMappingURL=processModules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"processModules.js","names":["_js","data","require","processModules","modules","filter","createModuleId","dev","includeAsyncPaths","projectRoot","serverRoot","sourceUrl","splitChunks","skipWrapping","computedAsyncModulePaths","isJsModule","map","module","wrapModule"],"sources":["../../../src/serializer/fork/processModules.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\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 */\n\nimport type { Module } from 'metro';\n\nimport { isJsModule, wrapModule } from './js';\n\nexport function processModules(\n modules: readonly Module[],\n {\n filter = () => true,\n createModuleId,\n dev,\n includeAsyncPaths,\n projectRoot,\n serverRoot,\n sourceUrl,\n splitChunks,\n skipWrapping,\n computedAsyncModulePaths,\n }: {\n splitChunks: boolean;\n filter?: (module: Module) => boolean;\n createModuleId: (module: string) => number;\n dev: boolean;\n includeAsyncPaths: boolean;\n projectRoot: string;\n serverRoot: string;\n sourceUrl: string | undefined;\n skipWrapping: boolean;\n computedAsyncModulePaths: Record<string, string> | null;\n }\n): readonly [Module, { src: string; paths: Record<string, string> }][] {\n return [...modules]\n .filter(isJsModule)\n .filter(filter)\n .map((module: Module) => [\n module,\n wrapModule(module, {\n splitChunks,\n createModuleId,\n dev,\n includeAsyncPaths,\n projectRoot,\n serverRoot,\n sourceUrl,\n skipWrapping,\n computedAsyncModulePaths,\n }),\n ]);\n}\n"],"mappings":";;;;;;AAUA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,SAASE,cAAcA,CAC5BC,OAA0B,EAC1B;EACEC,MAAM,GAAGA,CAAA,KAAM,IAAI;EACnBC,cAAc;EACdC,GAAG;EACHC,iBAAiB;EACjBC,WAAW;EACXC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,YAAY;EACZC;AAYF,CAAC,EACoE;EACrE,OAAO,CAAC,GAAGV,OAAO,CAAC,CAChBC,MAAM,CAACU,gBAAU,CAAC,CAClBV,MAAM,CAACA,MAAM,CAAC,CACdW,GAAG,CAAEC,MAAc,IAAK,CACvBA,MAAM,EACN,IAAAC,gBAAU,EAACD,MAAM,EAAE;IACjBL,WAAW;IACXN,cAAc;IACdC,GAAG;IACHC,iBAAiB;IACjBC,WAAW;IACXC,UAAU;IACVC,SAAS;IACTE,YAAY;IACZC;EACF,CAAC,CAAC,CACH,CAAC;AACN"}
1
+ {"version":3,"file":"processModules.js","sourceRoot":"","sources":["../../../src/serializer/fork/processModules.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,6BAA8C;AAE9C,SAAgB,cAAc,CAC5B,OAA0B,EAC1B,EACE,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,EACnB,cAAc,EACd,GAAG,EACH,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,wBAAwB,GAYzB;IAED,OAAO,CAAC,GAAG,OAAO,CAAC;SAChB,MAAM,CAAC,eAAU,CAAC;SAClB,MAAM,CAAC,MAAM,CAAC;SACd,GAAG,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC;QACvB,MAAM;QACN,IAAA,eAAU,EAAC,MAAM,EAAE;YACjB,WAAW;YACX,cAAc;YACd,GAAG;YACH,iBAAiB;YACjB,WAAW;YACX,UAAU;YACV,SAAS;YACT,YAAY;YACZ,wBAAwB;SACzB,CAAC;KACH,CAAC,CAAC;AACP,CAAC;AA3CD,wCA2CC"}
@@ -1,110 +1,79 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fileNameFromContents = fileNameFromContents;
7
- exports.filterJsModules = filterJsModules;
8
- exports.getCssSerialAssets = getCssSerialAssets;
9
- exports.getFileName = getFileName;
10
- function _js() {
11
- const data = require("metro/src/DeltaBundler/Serializers/helpers/js");
12
- _js = function () {
13
- return data;
14
- };
15
- return data;
16
- }
17
- function _path() {
18
- const data = _interopRequireDefault(require("path"));
19
- _path = function () {
20
- return data;
21
- };
22
- return data;
23
- }
24
- function _css() {
25
- const data = require("../transform-worker/css");
26
- _css = function () {
27
- return data;
28
- };
29
- return data;
30
- }
31
- function _hash() {
32
- const data = require("../utils/hash");
33
- _hash = function () {
34
- return data;
35
- };
36
- return data;
37
- }
38
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getFileName = exports.fileNameFromContents = exports.getCssSerialAssets = exports.filterJsModules = void 0;
7
+ const js_1 = require("metro/src/DeltaBundler/Serializers/helpers/js");
8
+ const path_1 = __importDefault(require("path"));
9
+ const css_1 = require("../transform-worker/css");
10
+ const hash_1 = require("../utils/hash");
39
11
  // s = static
40
12
  const STATIC_EXPORT_DIRECTORY = '_expo/static/css';
41
- function filterJsModules(dependencies, type, {
42
- processModuleFilter,
43
- projectRoot
44
- }) {
45
- const assets = [];
46
- for (const module of dependencies.values()) {
47
- if ((0, _js().isJsModule)(module) && processModuleFilter(module) && (0, _js().getJsOutput)(module).type === type && _path().default.relative(projectRoot, module.path) !== 'package.json') {
48
- assets.push(module);
13
+ function filterJsModules(dependencies, type, { processModuleFilter, projectRoot }) {
14
+ const assets = [];
15
+ for (const module of dependencies.values()) {
16
+ if ((0, js_1.isJsModule)(module) &&
17
+ processModuleFilter(module) &&
18
+ (0, js_1.getJsOutput)(module).type === type &&
19
+ path_1.default.relative(projectRoot, module.path) !== 'package.json') {
20
+ assets.push(module);
21
+ }
49
22
  }
50
- }
51
- return assets;
23
+ return assets;
52
24
  }
53
- function getCssSerialAssets(dependencies, {
54
- processModuleFilter,
55
- projectRoot
56
- }) {
57
- const assets = [];
58
- for (const module of filterJsModules(dependencies, 'js/module', {
59
- processModuleFilter,
60
- projectRoot
61
- })) {
62
- const cssMetadata = getCssMetadata(module);
63
- if (cssMetadata) {
64
- const contents = cssMetadata.code;
65
- const originFilename = _path().default.relative(projectRoot, module.path);
66
- const filename = _path().default.join(
67
- // Consistent location
68
- STATIC_EXPORT_DIRECTORY,
69
- // Hashed file contents + name for caching
70
- fileNameFromContents({
71
- // Stable filename for hashing in CI.
72
- filepath: originFilename,
73
- src: contents
74
- }) + '.css');
75
- assets.push({
76
- type: 'css',
77
- originFilename,
78
- filename,
79
- source: contents,
80
- metadata: {
81
- hmrId: (0, _css().pathToHtmlSafeName)(originFilename)
25
+ exports.filterJsModules = filterJsModules;
26
+ function getCssSerialAssets(dependencies, { processModuleFilter, projectRoot }) {
27
+ const assets = [];
28
+ for (const module of filterJsModules(dependencies, 'js/module', {
29
+ processModuleFilter,
30
+ projectRoot,
31
+ })) {
32
+ const cssMetadata = getCssMetadata(module);
33
+ if (cssMetadata) {
34
+ const contents = cssMetadata.code;
35
+ const originFilename = path_1.default.relative(projectRoot, module.path);
36
+ const filename = path_1.default.join(
37
+ // Consistent location
38
+ STATIC_EXPORT_DIRECTORY,
39
+ // Hashed file contents + name for caching
40
+ fileNameFromContents({
41
+ // Stable filename for hashing in CI.
42
+ filepath: originFilename,
43
+ src: contents,
44
+ }) + '.css');
45
+ assets.push({
46
+ type: 'css',
47
+ originFilename,
48
+ filename,
49
+ source: contents,
50
+ metadata: {
51
+ hmrId: (0, css_1.pathToHtmlSafeName)(originFilename),
52
+ },
53
+ });
82
54
  }
83
- });
84
55
  }
85
- }
86
- return assets;
56
+ return assets;
87
57
  }
58
+ exports.getCssSerialAssets = getCssSerialAssets;
88
59
  function getCssMetadata(module) {
89
- var _module$output$;
90
- const data = (_module$output$ = module.output[0]) === null || _module$output$ === void 0 ? void 0 : _module$output$.data;
91
- if (data && typeof data === 'object' && 'css' in data) {
92
- if (typeof data.css !== 'object' || !('code' in data.css)) {
93
- throw new Error(`Unexpected CSS metadata in Metro module (${module.path}): ${JSON.stringify(data.css)}`);
60
+ const data = module.output[0]?.data;
61
+ if (data && typeof data === 'object' && 'css' in data) {
62
+ if (typeof data.css !== 'object' || !('code' in data.css)) {
63
+ throw new Error(`Unexpected CSS metadata in Metro module (${module.path}): ${JSON.stringify(data.css)}`);
64
+ }
65
+ return data.css;
94
66
  }
95
- return data.css;
96
- }
97
- return null;
67
+ return null;
98
68
  }
99
- function fileNameFromContents({
100
- filepath,
101
- src
102
- }) {
103
- // Decode if the path is encoded from the Metro dev server, then normalize paths for Windows support.
104
- const decoded = decodeURIComponent(filepath).replace(/\\/g, '/');
105
- return getFileName(decoded) + '-' + (0, _hash().hashString)(src);
69
+ function fileNameFromContents({ filepath, src }) {
70
+ // Decode if the path is encoded from the Metro dev server, then normalize paths for Windows support.
71
+ const decoded = decodeURIComponent(filepath).replace(/\\/g, '/');
72
+ return getFileName(decoded) + '-' + (0, hash_1.hashString)(src);
106
73
  }
74
+ exports.fileNameFromContents = fileNameFromContents;
107
75
  function getFileName(module) {
108
- return _path().default.basename(module).replace(/\.[^.]+$/, '');
76
+ return path_1.default.basename(module).replace(/\.[^.]+$/, '');
109
77
  }
78
+ exports.getFileName = getFileName;
110
79
  //# sourceMappingURL=getCssDeps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCssDeps.js","names":["_js","data","require","_path","_interopRequireDefault","_css","_hash","obj","__esModule","default","STATIC_EXPORT_DIRECTORY","filterJsModules","dependencies","type","processModuleFilter","projectRoot","assets","module","values","isJsModule","getJsOutput","path","relative","push","getCssSerialAssets","cssMetadata","getCssMetadata","contents","code","originFilename","filename","join","fileNameFromContents","filepath","src","source","metadata","hmrId","pathToHtmlSafeName","_module$output$","output","css","Error","JSON","stringify","decoded","decodeURIComponent","replace","getFileName","hashString","basename"],"sources":["../../src/serializer/getCssDeps.ts"],"sourcesContent":["import type { Module } from 'metro';\nimport { getJsOutput, isJsModule } from 'metro/src/DeltaBundler/Serializers/helpers/js';\nimport path from 'path';\n\nimport { SerialAsset } from './serializerAssets';\nimport { pathToHtmlSafeName } from '../transform-worker/css';\nimport { hashString } from '../utils/hash';\n\nexport type ReadOnlyDependencies<T = any> = ReadonlyMap<string, Module<T>>;\n\ntype Options = {\n processModuleFilter: (modules: Module) => boolean;\n assetPlugins: readonly string[];\n platform?: string | null;\n projectRoot: string;\n publicPath: string;\n};\n\ntype MetroModuleCSSMetadata = {\n code: string;\n lineCount: number;\n map: any[];\n};\n\n// s = static\nconst STATIC_EXPORT_DIRECTORY = '_expo/static/css';\n\nexport type JSModule = Module<{\n data: {\n code: string;\n map: unknown;\n lineCount: number;\n css?: {\n code: string;\n map: unknown;\n lineCount: number;\n skipCache?: boolean;\n };\n };\n type: 'js/module';\n}> & {\n unstable_transformResultKey?: string;\n};\n\nexport function filterJsModules(\n dependencies: ReadOnlyDependencies,\n type: 'js/script' | 'js/module' | 'js/module/asset',\n { processModuleFilter, projectRoot }: Pick<Options, 'projectRoot' | 'processModuleFilter'>\n) {\n const assets: JSModule[] = [];\n\n for (const module of dependencies.values()) {\n if (\n isJsModule(module) &&\n processModuleFilter(module) &&\n getJsOutput(module).type === type &&\n path.relative(projectRoot, module.path) !== 'package.json'\n ) {\n assets.push(module as JSModule);\n }\n }\n return assets;\n}\n\nexport function getCssSerialAssets<T extends any>(\n dependencies: ReadOnlyDependencies<T>,\n { processModuleFilter, projectRoot }: Pick<Options, 'projectRoot' | 'processModuleFilter'>\n): SerialAsset[] {\n const assets: SerialAsset[] = [];\n\n for (const module of filterJsModules(dependencies, 'js/module', {\n processModuleFilter,\n projectRoot,\n })) {\n const cssMetadata = getCssMetadata(module);\n if (cssMetadata) {\n const contents = cssMetadata.code;\n const originFilename = path.relative(projectRoot, module.path);\n\n const filename = path.join(\n // Consistent location\n STATIC_EXPORT_DIRECTORY,\n // Hashed file contents + name for caching\n fileNameFromContents({\n // Stable filename for hashing in CI.\n filepath: originFilename,\n src: contents,\n }) + '.css'\n );\n assets.push({\n type: 'css',\n originFilename,\n filename,\n source: contents,\n metadata: {\n hmrId: pathToHtmlSafeName(originFilename),\n },\n });\n }\n }\n\n return assets;\n}\n\nfunction getCssMetadata(module: JSModule): MetroModuleCSSMetadata | null {\n const data = module.output[0]?.data;\n if (data && typeof data === 'object' && 'css' in data) {\n if (typeof data.css !== 'object' || !('code' in (data as any).css)) {\n throw new Error(\n `Unexpected CSS metadata in Metro module (${module.path}): ${JSON.stringify(data.css)}`\n );\n }\n return data.css as MetroModuleCSSMetadata;\n }\n return null;\n}\n\nexport function fileNameFromContents({ filepath, src }: { filepath: string; src: string }): string {\n // Decode if the path is encoded from the Metro dev server, then normalize paths for Windows support.\n const decoded = decodeURIComponent(filepath).replace(/\\\\/g, '/');\n return getFileName(decoded) + '-' + hashString(src);\n}\n\nexport function getFileName(module: string) {\n return path.basename(module).replace(/\\.[^.]+$/, '');\n}\n"],"mappings":";;;;;;;;;AACA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,MAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,KAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2C,SAAAG,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAkB3C;AACA,MAAMG,uBAAuB,GAAG,kBAAkB;AAmB3C,SAASC,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C"}
@@ -1,24 +1,14 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isExpoJsOutput = isExpoJsOutput;
7
- exports.isTransformOptionTruthy = isTransformOptionTruthy;
8
- /**
9
- * Copyright © 2023-present 650 Industries (Expo). All rights reserved.
10
- *
11
- * This source code is licensed under the MIT license found in the
12
- * LICENSE file in the root directory of this source tree.
13
- */
14
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTransformOptionTruthy = exports.isExpoJsOutput = void 0;
15
4
  function isExpoJsOutput(output) {
16
- return 'data' in output && typeof output.data === 'object';
5
+ return 'data' in output && typeof output.data === 'object';
17
6
  }
18
-
7
+ exports.isExpoJsOutput = isExpoJsOutput;
19
8
  // Because transform options can be passed directly during export, or through a query parameter
20
9
  // during a request, we need to normalize the options.
21
10
  function isTransformOptionTruthy(option) {
22
- return option === true || option === 'true' || option === '1';
11
+ return option === true || option === 'true' || option === '1';
23
12
  }
13
+ exports.isTransformOptionTruthy = isTransformOptionTruthy;
24
14
  //# sourceMappingURL=jsOutput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsOutput.js","names":["isExpoJsOutput","output","data","isTransformOptionTruthy","option"],"sources":["../../src/serializer/jsOutput.ts"],"sourcesContent":["/**\n * Copyright © 2023-present 650 Industries (Expo). All rights reserved.\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';\n\nexport type JSFileType = 'js/script' | 'js/module' | 'js/module/asset';\n\nexport type JsOutput = {\n data: {\n code: string;\n lineCount: number;\n map: MetroSourceMapSegmentTuple[];\n functionMap: FBSourceFunctionMap | null;\n\n css?: {\n code: string;\n lineCount: number;\n map: MetroSourceMapSegmentTuple[];\n functionMap: FBSourceFunctionMap | null;\n };\n };\n type: JSFileType;\n};\n\nexport type ExpoJsOutput = Omit<JsOutput, 'data'> & {\n data: JsOutput['data'] & {\n profiling?: {\n start: number;\n end: number;\n duration: number;\n };\n css?: {\n code: string;\n lineCount: number;\n map: unknown[];\n functionMap: null;\n skipCache?: boolean;\n };\n };\n};\n\nexport function isExpoJsOutput(output: any): output is ExpoJsOutput {\n return 'data' in output && typeof output.data === 'object';\n}\n\n// Because transform options can be passed directly during export, or through a query parameter\n// during a request, we need to normalize the options.\nexport function isTransformOptionTruthy(option: any): boolean {\n return option === true || option === 'true' || option === '1';\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAuCO,SAASA,cAAcA,CAACC,MAAW,EAA0B;EAClE,OAAO,MAAM,IAAIA,MAAM,IAAI,OAAOA,MAAM,CAACC,IAAI,KAAK,QAAQ;AAC5D;;AAEA;AACA;AACO,SAASC,uBAAuBA,CAACC,MAAW,EAAW;EAC5D,OAAOA,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAK,MAAM,IAAIA,MAAM,KAAK,GAAG;AAC/D"}
1
+ {"version":3,"file":"jsOutput.js","sourceRoot":"","sources":["../../src/serializer/jsOutput.ts"],"names":[],"mappings":";;;AA4CA,SAAgB,cAAc,CAAC,MAAW;IACxC,OAAO,MAAM,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC7D,CAAC;AAFD,wCAEC;AAED,+FAA+F;AAC/F,sDAAsD;AACtD,SAAgB,uBAAuB,CAAC,MAAW;IACjD,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,GAAG,CAAC;AAChE,CAAC;AAFD,0DAEC"}