mirror of
https://github.com/status-im/metro.git
synced 2025-02-28 02:30:29 +00:00
Remove logic to calculate polyfills from Resolver
Reviewed By: jeanlauliac Differential Revision: D6674424 fbshipit-source-id: 20c0ace056150c1f6910edc7eadf8effb9ddf38d
This commit is contained in:
parent
fbe441febd
commit
eb489bf105
@ -16,7 +16,9 @@ const DeltaCalculator = require('./DeltaCalculator');
|
||||
|
||||
const addParamsToDefineCall = require('../lib/addParamsToDefineCall');
|
||||
const createModuleIdFactory = require('../lib/createModuleIdFactory');
|
||||
const defaults = require('../defaults');
|
||||
const nullthrows = require('fbjs/lib/nullthrows');
|
||||
const path = require('path');
|
||||
const removeInlineRequiresBlacklistFromOptions = require('../lib/removeInlineRequiresBlacklistFromOptions');
|
||||
|
||||
const {EventEmitter} = require('events');
|
||||
@ -328,21 +330,17 @@ class DeltaTransformer extends EventEmitter {
|
||||
platform: this._bundleOptions.platform,
|
||||
}).concat(this._polyfillModuleNames);
|
||||
|
||||
// The module system dependencies are scripts that need to be included at
|
||||
// the very beginning of the bundle (before any polyfill).
|
||||
const moduleSystemDeps = this._resolver.getModuleSystemDependencies({
|
||||
dev: this._bundleOptions.dev,
|
||||
});
|
||||
|
||||
const modules = moduleSystemDeps.concat(
|
||||
polyfillModuleNames.map((polyfillModuleName, idx) =>
|
||||
// Build the module system dependencies (scripts that need to
|
||||
// be included at the very beginning of the bundle) + any polifyll.
|
||||
const modules = this._getModuleSystemDependencies()
|
||||
.concat(polyfillModuleNames)
|
||||
.map(polyfillModuleName =>
|
||||
this._resolver.getDependencyGraph().createPolyfill({
|
||||
file: polyfillModuleName,
|
||||
id: polyfillModuleName,
|
||||
dependencies: [],
|
||||
}),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
return await this._transformModules(
|
||||
modules,
|
||||
@ -534,6 +532,16 @@ class DeltaTransformer extends EventEmitter {
|
||||
_onFileChange = () => {
|
||||
this.emit('change');
|
||||
};
|
||||
|
||||
_getModuleSystemDependencies() {
|
||||
const prelude = this._bundleOptions.dev
|
||||
? path.resolve(__dirname, '../Resolver/polyfills/prelude_dev.js')
|
||||
: path.resolve(__dirname, '../Resolver/polyfills/prelude.js');
|
||||
|
||||
const moduleSystem = defaults.moduleSystem;
|
||||
|
||||
return [prelude, moduleSystem];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DeltaTransformer;
|
||||
|
@ -14,26 +14,22 @@
|
||||
|
||||
const DependencyGraph = require('../node-haste/DependencyGraph');
|
||||
|
||||
const defaults = require('../defaults');
|
||||
|
||||
const {
|
||||
compactMapping,
|
||||
fromRawMappings,
|
||||
toRawMappings,
|
||||
} = require('metro-source-map');
|
||||
const pathJoin = require('path').join;
|
||||
|
||||
import type Module, {HasteImpl, TransformCode} from '../node-haste/Module';
|
||||
import type {CompactRawMappings} from '../lib/SourceMap';
|
||||
import type {PostMinifyProcess} from '../Bundler';
|
||||
import type {Reporter} from '../lib/reporting';
|
||||
import typeof {minify as MinifyCode} from '../JSTransformer/worker';
|
||||
import type {GlobalTransformCache} from '../lib/GlobalTransformCache';
|
||||
import type {CompactRawMappings} from '../lib/SourceMap';
|
||||
import type {
|
||||
TransformCache,
|
||||
GetTransformCacheKey,
|
||||
} from '../lib/TransformCaching';
|
||||
import type {GlobalTransformCache} from '../lib/GlobalTransformCache';
|
||||
|
||||
import typeof {minify as MinifyCode} from '../JSTransformer/worker';
|
||||
import type {Reporter} from '../lib/reporting';
|
||||
import type {HasteImpl, TransformCode} from '../node-haste/Module';
|
||||
|
||||
type Options = {|
|
||||
+assetExts: Array<string>,
|
||||
@ -61,16 +57,12 @@ type Options = {|
|
||||
|
||||
class Resolver {
|
||||
_depGraph: DependencyGraph;
|
||||
_getPolyfills: ({platform: ?string}) => $ReadOnlyArray<string>;
|
||||
_minifyCode: MinifyCode;
|
||||
_postMinifyProcess: PostMinifyProcess;
|
||||
_polyfillModuleNames: Array<string>;
|
||||
|
||||
constructor(opts: Options, depGraph: DependencyGraph) {
|
||||
this._getPolyfills = opts.getPolyfills;
|
||||
this._minifyCode = opts.minifyCode;
|
||||
this._postMinifyProcess = opts.postMinifyProcess;
|
||||
this._polyfillModuleNames = opts.polyfillModuleNames || [];
|
||||
this._depGraph = depGraph;
|
||||
}
|
||||
|
||||
@ -100,22 +92,6 @@ class Resolver {
|
||||
return new Resolver(opts, depGraph);
|
||||
}
|
||||
|
||||
getModuleSystemDependencies({dev = true}: {dev?: boolean}): Array<Module> {
|
||||
const prelude = dev
|
||||
? pathJoin(__dirname, 'polyfills/prelude_dev.js')
|
||||
: pathJoin(__dirname, 'polyfills/prelude.js');
|
||||
|
||||
const moduleSystem = defaults.moduleSystem;
|
||||
|
||||
return [prelude, moduleSystem].map(moduleName =>
|
||||
this._depGraph.createPolyfill({
|
||||
file: moduleName,
|
||||
id: moduleName,
|
||||
dependencies: [],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async minifyModule(
|
||||
path: string,
|
||||
code: string,
|
||||
|
Loading…
x
Reference in New Issue
Block a user