diff --git a/packager/react-packager/src/ModuleGraph/Graph.js b/packager/react-packager/src/ModuleGraph/Graph.js index fe13718a9d9f99..21a84c29ab8510 100644 --- a/packager/react-packager/src/ModuleGraph/Graph.js +++ b/packager/react-packager/src/ModuleGraph/Graph.js @@ -50,7 +50,7 @@ type LoadQueue = Async$Queue<{id: string, parent: string}, Callback>>; const createParentModule = - () => ({file: {code: '', isPolyfill: false, path: ''}, dependencies: []}); + () => ({file: {code: '', type: 'script', path: ''}, dependencies: []}); const noop = () => {}; const NO_OPTIONS = {}; diff --git a/packager/react-packager/src/ModuleGraph/types.flow.js b/packager/react-packager/src/ModuleGraph/types.flow.js index 6eb2801c1a1a04..705c328baa6b26 100644 --- a/packager/react-packager/src/ModuleGraph/types.flow.js +++ b/packager/react-packager/src/ModuleGraph/types.flow.js @@ -40,11 +40,13 @@ type Dependency = {| export type File = {| code: string, - isPolyfill: boolean, map?: ?Object, path: string, + type: FileTypes, |}; +type FileTypes = 'module' | 'script'; + export type Module = {| dependencies: Array, file: File, @@ -82,9 +84,9 @@ export type TransformedFile = { code: string, file: string, hasteID: ?string, - isPolyfill: boolean, package?: PackageData, transformed: {[variant: string]: TransformResult}, + type: FileTypes, }; export type PackageData = {| diff --git a/packager/react-packager/src/ModuleGraph/worker/__tests__/transform-module-test.js b/packager/react-packager/src/ModuleGraph/worker/__tests__/transform-module-test.js index b7c56b9903b57e..afdf434674bb88 100644 --- a/packager/react-packager/src/ModuleGraph/worker/__tests__/transform-module-test.js +++ b/packager/react-packager/src/ModuleGraph/worker/__tests__/transform-module-test.js @@ -62,16 +62,16 @@ describe('transforming JS modules:', () => { }); }); - it('sets `isPolyfill` to `false` by default', done => { + it('sets `type` to `"module"` by default', done => { transformModule(sourceCode, options(), (error, result) => { - expect(result).toEqual(objectContaining({isPolyfill: false})); + expect(result).toEqual(objectContaining({type: 'module'})); done(); }); }); - it('sets `isPolyfill` to `true` if the input is a polyfill', done => { + it('sets `type` to `"script"` if the input is a polyfill', done => { transformModule(sourceCode, {...options(), polyfill: true}, (error, result) => { - expect(result).toEqual(objectContaining({isPolyfill: true})); + expect(result).toEqual(objectContaining({type: 'script'})); done(); }); }); diff --git a/packager/react-packager/src/ModuleGraph/worker/transform-module.js b/packager/react-packager/src/ModuleGraph/worker/transform-module.js index 805f75bae813a4..81cbde33fa13cc 100644 --- a/packager/react-packager/src/ModuleGraph/worker/transform-module.js +++ b/packager/react-packager/src/ModuleGraph/worker/transform-module.js @@ -75,9 +75,9 @@ function transformModule( callback(null, { code, file: filename, - isPolyfill: !!options.polyfill, hasteID: annotations.providesModule || annotations.provide || null, transformed, + type: options.polyfill ? 'script' : 'module', }); }); } @@ -105,8 +105,8 @@ function transformJSON(json, options, callback) { code: json, file: filename, hasteID: value.name, - isPolyfill: false, transformed, + type: 'module', }; if (basename(filename) === 'package.json') {