RM Polyfill.js: @flow
Reviewed By: davidaurelio Differential Revision: D4118256 fbshipit-source-id: b9d906cd94c0548c28a62fa636c6da7bcf894ba9
This commit is contained in:
parent
35614db349
commit
ea536dd4bf
|
@ -56,6 +56,17 @@ export type FastFs = {
|
|||
};
|
||||
export type DepGraphHelpers = {isNodeModulesDir: (filePath: string) => boolean};
|
||||
|
||||
export type ConstructorArgs = {
|
||||
file: string,
|
||||
fastfs: FastFs,
|
||||
moduleCache: ModuleCache,
|
||||
cache: Cache,
|
||||
extractor: Extractor,
|
||||
transformCode: TransformCode,
|
||||
depGraphHelpers: DepGraphHelpers,
|
||||
options: Options,
|
||||
};
|
||||
|
||||
class Module {
|
||||
|
||||
path: string;
|
||||
|
@ -81,16 +92,7 @@ class Module {
|
|||
transformCode,
|
||||
depGraphHelpers,
|
||||
options,
|
||||
}: {
|
||||
file: string,
|
||||
fastfs: FastFs,
|
||||
moduleCache: ModuleCache,
|
||||
cache: Cache,
|
||||
extractor: Extractor,
|
||||
transformCode: TransformCode,
|
||||
depGraphHelpers: DepGraphHelpers,
|
||||
options: Options,
|
||||
}) {
|
||||
}: ConstructorArgs) {
|
||||
if (!isAbsolutePath(file)) {
|
||||
throw new Error('Expected file to be absolute path but got ' + file);
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ class ModuleCache {
|
|||
}
|
||||
|
||||
createPolyfill({file}: {file: string}) {
|
||||
/* $FlowFixMe: there are missing arguments. */
|
||||
return new Polyfill({
|
||||
file,
|
||||
cache: this._cache,
|
||||
|
|
|
@ -1,9 +1,29 @@
|
|||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const Module = require('./Module');
|
||||
|
||||
import type {ConstructorArgs} from './Module';
|
||||
|
||||
class Polyfill extends Module {
|
||||
constructor(options) {
|
||||
|
||||
_id: string;
|
||||
_dependencies: Array<string>;
|
||||
|
||||
constructor(options: ConstructorArgs & {
|
||||
id: string,
|
||||
dependencies: Array<string>,
|
||||
}) {
|
||||
super(options);
|
||||
this._id = options.id;
|
||||
this._dependencies = options.dependencies;
|
||||
|
|
Loading…
Reference in New Issue