metro 0.76.2 → 0.76.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 (44) hide show
  1. package/package.json +22 -22
  2. package/src/Bundler/util.js +27 -3
  3. package/src/Bundler/util.js.flow +29 -3
  4. package/src/DeltaBundler/Graph.js +40 -26
  5. package/src/DeltaBundler/Graph.js.flow +42 -23
  6. package/src/DeltaBundler/Serializers/baseJSBundle.js +1 -0
  7. package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -0
  8. package/src/DeltaBundler/Serializers/getRamBundleInfo.js +1 -0
  9. package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +3 -1
  10. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +1 -0
  11. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +3 -0
  12. package/src/DeltaBundler/Serializers/sourceMapGenerator.js +1 -0
  13. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +10 -12
  14. package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +3 -8
  15. package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -4
  16. package/src/DeltaBundler/types.d.ts +2 -1
  17. package/src/DeltaBundler/types.flow.js.flow +2 -1
  18. package/src/HmrServer.js +3 -3
  19. package/src/HmrServer.js.flow +5 -3
  20. package/src/IncrementalBundler.js +7 -6
  21. package/src/IncrementalBundler.js.flow +8 -6
  22. package/src/Server.js +34 -8
  23. package/src/Server.js.flow +48 -14
  24. package/src/index.flow.js +6 -0
  25. package/src/index.flow.js.flow +6 -0
  26. package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js +16 -0
  27. package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +20 -0
  28. package/src/integration_tests/execBundle.js +3 -0
  29. package/src/integration_tests/execBundle.js.flow +4 -1
  30. package/src/integration_tests/metro.config.js +5 -0
  31. package/src/lib/getAppendScripts.js +1 -0
  32. package/src/lib/getAppendScripts.js.flow +12 -10
  33. package/src/lib/getGraphId.js +2 -7
  34. package/src/lib/getGraphId.js.flow +3 -3
  35. package/src/lib/getPrependedScripts.js +1 -2
  36. package/src/lib/getPrependedScripts.js.flow +1 -2
  37. package/src/lib/parseOptionsFromUrl.js +1 -0
  38. package/src/lib/parseOptionsFromUrl.js.flow +1 -0
  39. package/src/lib/splitBundleOptions.js +1 -0
  40. package/src/lib/splitBundleOptions.js.flow +1 -0
  41. package/src/lib/transformHelpers.js +1 -2
  42. package/src/lib/transformHelpers.js.flow +1 -2
  43. package/src/shared/types.d.ts +2 -0
  44. package/src/shared/types.flow.js.flow +2 -0
@@ -13,6 +13,9 @@
13
13
 
14
14
  const vm = require('vm');
15
15
 
16
- module.exports = function execBundle(code: string, context: {...} = {}): mixed {
16
+ module.exports = function execBundle(code: string, context: any = {}): mixed {
17
+ if (vm.isContext(context)) {
18
+ return vm.runInContext(code, context);
19
+ }
17
20
  return vm.runInNewContext(code, context);
18
21
  };
@@ -45,4 +45,9 @@ module.exports = {
45
45
  ramGroups: [],
46
46
  }),
47
47
  },
48
+ serializer: {
49
+ getPolyfills: () => [
50
+ require.resolve("./basic_bundle/loadBundleAsyncForTest"),
51
+ ],
52
+ },
48
53
  };
@@ -53,6 +53,7 @@ function getAppendScripts(entryPoint, modules, options) {
53
53
  sourceMapString(modules, {
54
54
  processModuleFilter: () => true,
55
55
  excludeSource: false,
56
+ shouldAddToIgnoreList: options.shouldAddToIgnoreList,
56
57
  })
57
58
  )
58
59
  : nullthrows(options.sourceMapUrl);
@@ -20,17 +20,18 @@ const sourceMapString = require('../DeltaBundler/Serializers/sourceMapString');
20
20
  const countLines = require('./countLines');
21
21
  const nullthrows = require('nullthrows');
22
22
 
23
- type Options<T: number | string> = {
24
- +asyncRequireModulePath: string,
25
- +createModuleId: string => T,
26
- +getRunModuleStatement: T => string,
27
- +inlineSourceMap: ?boolean,
28
- +runBeforeMainModule: $ReadOnlyArray<string>,
29
- +runModule: boolean,
30
- +sourceMapUrl: ?string,
31
- +sourceUrl: ?string,
23
+ type Options<T: number | string> = $ReadOnly<{
24
+ asyncRequireModulePath: string,
25
+ createModuleId: string => T,
26
+ getRunModuleStatement: T => string,
27
+ inlineSourceMap: ?boolean,
28
+ runBeforeMainModule: $ReadOnlyArray<string>,
29
+ runModule: boolean,
30
+ shouldAddToIgnoreList: (Module<>) => boolean,
31
+ sourceMapUrl: ?string,
32
+ sourceUrl: ?string,
32
33
  ...
33
- };
34
+ }>;
34
35
 
35
36
  function getAppendScripts<T: number | string>(
36
37
  entryPoint: string,
@@ -73,6 +74,7 @@ function getAppendScripts<T: number | string>(
73
74
  sourceMapString(modules, {
74
75
  processModuleFilter: (): boolean => true,
75
76
  excludeSource: false,
77
+ shouldAddToIgnoreList: options.shouldAddToIgnoreList,
76
78
  }),
77
79
  )
78
80
  : nullthrows(options.sourceMapUrl);
@@ -15,12 +15,7 @@ const canonicalize = require("metro-core/src/canonicalize");
15
15
  function getGraphId(
16
16
  entryFile,
17
17
  options,
18
- {
19
- shallow,
20
- experimentalImportBundleSupport,
21
- unstable_allowRequireContext,
22
- resolverOptions,
23
- }
18
+ { shallow, lazy, unstable_allowRequireContext, resolverOptions }
24
19
  ) {
25
20
  return JSON.stringify(
26
21
  {
@@ -35,7 +30,7 @@ function getGraphId(
35
30
  unstable_disableES6Transforms: options.unstable_disableES6Transforms,
36
31
  platform: options.platform != null ? options.platform : null,
37
32
  type: options.type,
38
- experimentalImportBundleSupport,
33
+ lazy,
39
34
  unstable_allowRequireContext,
40
35
  shallow,
41
36
  unstable_transformProfile:
@@ -23,12 +23,12 @@ function getGraphId(
23
23
  options: TransformInputOptions,
24
24
  {
25
25
  shallow,
26
- experimentalImportBundleSupport,
26
+ lazy,
27
27
  unstable_allowRequireContext,
28
28
  resolverOptions,
29
29
  }: $ReadOnly<{
30
30
  shallow: boolean,
31
- experimentalImportBundleSupport: boolean,
31
+ lazy: boolean,
32
32
  unstable_allowRequireContext: boolean,
33
33
  resolverOptions: ResolverInputOptions,
34
34
  }>,
@@ -46,7 +46,7 @@ function getGraphId(
46
46
  unstable_disableES6Transforms: options.unstable_disableES6Transforms,
47
47
  platform: options.platform != null ? options.platform : null,
48
48
  type: options.type,
49
- experimentalImportBundleSupport,
49
+ lazy,
50
50
  unstable_allowRequireContext,
51
51
  shallow,
52
52
  unstable_transformProfile:
@@ -57,8 +57,7 @@ async function getPrependedScripts(
57
57
  config.transformer.unstable_allowRequireContext,
58
58
  transformOptions,
59
59
  onProgress: null,
60
- experimentalImportBundleSupport:
61
- config.server.experimentalImportBundleSupport,
60
+ lazy: false,
62
61
  unstable_enablePackageExports:
63
62
  config.resolver.unstable_enablePackageExports,
64
63
  shallow: false,
@@ -67,8 +67,7 @@ async function getPrependedScripts(
67
67
  config.transformer.unstable_allowRequireContext,
68
68
  transformOptions,
69
69
  onProgress: null,
70
- experimentalImportBundleSupport:
71
- config.server.experimentalImportBundleSupport,
70
+ lazy: false,
72
71
  unstable_enablePackageExports:
73
72
  config.resolver.unstable_enablePackageExports,
74
73
  shallow: false,
@@ -45,6 +45,7 @@ module.exports = function parseOptionsFromUrl(requestUrl, platforms) {
45
45
  excludeSource: getBoolean(query, "excludeSource", false),
46
46
  hot: true,
47
47
  inlineSourceMap: getBoolean(query, "inlineSourceMap", false),
48
+ lazy: getBoolean(query, "lazy", false),
48
49
  minify: getBoolean(query, "minify", false),
49
50
  modulesOnly: getBoolean(query, "modulesOnly", false),
50
51
  onProgress: null,
@@ -60,6 +60,7 @@ module.exports = function parseOptionsFromUrl(
60
60
  excludeSource: getBoolean(query, 'excludeSource', false),
61
61
  hot: true,
62
62
  inlineSourceMap: getBoolean(query, 'inlineSourceMap', false),
63
+ lazy: getBoolean(query, 'lazy', false),
63
64
  minify: getBoolean(query, 'minify', false),
64
65
  modulesOnly: getBoolean(query, 'modulesOnly', false),
65
66
  onProgress: null,
@@ -39,6 +39,7 @@ function splitBundleOptions(options) {
39
39
  },
40
40
  graphOptions: {
41
41
  shallow: options.shallow,
42
+ lazy: options.lazy,
42
43
  },
43
44
  onProgress: options.onProgress,
44
45
  };
@@ -41,6 +41,7 @@ function splitBundleOptions(options: BundleOptions): SplitBundleOptions {
41
41
  },
42
42
  graphOptions: {
43
43
  shallow: options.shallow,
44
+ lazy: options.lazy,
44
45
  },
45
46
  onProgress: options.onProgress,
46
47
  };
@@ -67,8 +67,7 @@ async function calcTransformerOptions(
67
67
  ),
68
68
  transformOptions: options,
69
69
  onProgress: null,
70
- experimentalImportBundleSupport:
71
- config.server.experimentalImportBundleSupport,
70
+ lazy: false,
72
71
  unstable_allowRequireContext:
73
72
  config.transformer.unstable_allowRequireContext,
74
73
  unstable_enablePackageExports:
@@ -85,8 +85,7 @@ async function calcTransformerOptions(
85
85
  ),
86
86
  transformOptions: options,
87
87
  onProgress: null,
88
- experimentalImportBundleSupport:
89
- config.server.experimentalImportBundleSupport,
88
+ lazy: false,
90
89
  unstable_allowRequireContext:
91
90
  config.transformer.unstable_allowRequireContext,
92
91
  unstable_enablePackageExports:
@@ -46,6 +46,7 @@ export interface BundleOptions {
46
46
  readonly excludeSource: boolean;
47
47
  readonly hot: boolean;
48
48
  readonly inlineSourceMap: boolean;
49
+ readonly lazy: boolean;
49
50
  minify: boolean;
50
51
  readonly modulesOnly: boolean;
51
52
  onProgress?: (doneCont: number, totalCount: number) => unknown;
@@ -73,6 +74,7 @@ export interface SerializerOptions {
73
74
  }
74
75
 
75
76
  export interface GraphOptions {
77
+ readonly lazy: boolean;
76
78
  readonly shallow: boolean;
77
79
  }
78
80
 
@@ -50,6 +50,7 @@ export type BundleOptions = {
50
50
  +excludeSource: boolean,
51
51
  +hot: boolean,
52
52
  +inlineSourceMap: boolean,
53
+ +lazy: boolean,
53
54
  minify: boolean,
54
55
  +modulesOnly: boolean,
55
56
  onProgress: ?(doneCont: number, totalCount: number) => mixed,
@@ -76,6 +77,7 @@ export type SerializerOptions = {
76
77
  };
77
78
 
78
79
  export type GraphOptions = {
80
+ +lazy: boolean,
79
81
  +shallow: boolean,
80
82
  };
81
83