mirror of https://github.com/status-im/metro.git
Backout "Use numeric identifiers when building a bundle"
Summary: public The reverted change doesn’t play nice with inline requires, let’s revert it for now. I will bring it back after fixing it or adapting inline requires Reviewed By: martinbigio Differential Revision: D2854771 fb-gh-sync-id: 32fdbf8ad51240a9075b26502decb6328eed4b29
This commit is contained in:
parent
741cb48fa2
commit
baa6d7fb24
|
@ -41,10 +41,10 @@ class Bundle extends BundleBase {
|
|||
response,
|
||||
module,
|
||||
transformed.code
|
||||
).then(({code, id}) => {
|
||||
).then(({code, name}) => {
|
||||
const moduleTransport = new ModuleTransport({
|
||||
code,
|
||||
name: id,
|
||||
name,
|
||||
map: transformed.map,
|
||||
sourceCode: transformed.sourceCode,
|
||||
sourcePath: transformed.sourcePath,
|
||||
|
@ -76,7 +76,7 @@ class Bundle extends BundleBase {
|
|||
}
|
||||
|
||||
_addRequireCall(moduleId) {
|
||||
const code = `;require(${JSON.stringify(moduleId)});`;
|
||||
const code = ';require("' + moduleId + '");';
|
||||
const name = 'require-' + moduleId;
|
||||
super.addModule(new ModuleTransport({
|
||||
name,
|
||||
|
|
|
@ -10,23 +10,16 @@
|
|||
|
||||
jest
|
||||
.setMock('worker-farm', () => () => undefined)
|
||||
.dontMock('absolute-path')
|
||||
.dontMock('underscore')
|
||||
.dontMock('../../lib/ModuleTransport')
|
||||
.dontMock('../../DependencyResolver/AssetModule')
|
||||
.dontMock('../../DependencyResolver/Module')
|
||||
.dontMock('../../DependencyResolver/lib/getAssetDataFromName')
|
||||
.setMock('uglify-js')
|
||||
.dontMock('../');
|
||||
|
||||
jest.mock('fs');
|
||||
|
||||
var AssetModule = require('../../DependencyResolver/AssetModule');
|
||||
var Bundler = require('../');
|
||||
var JSTransformer = require('../../JSTransformer');
|
||||
var Module = require('../../DependencyResolver/Module');
|
||||
var Resolver = require('../../Resolver');
|
||||
|
||||
var sizeOf = require('image-size');
|
||||
var fs = require('fs');
|
||||
|
||||
|
@ -41,14 +34,6 @@ describe('Bundler', function() {
|
|||
isJSON,
|
||||
resolution,
|
||||
}) {
|
||||
if (isAsset) {
|
||||
const module = new AssetModule({
|
||||
file: path,
|
||||
cache: {get: () => Promise.resolve(path)}
|
||||
});
|
||||
module.getName = () => Promise.resolve(id);
|
||||
return module;
|
||||
}
|
||||
return {
|
||||
path,
|
||||
resolution,
|
||||
|
@ -66,8 +51,6 @@ describe('Bundler', function() {
|
|||
var bundler;
|
||||
var assetServer;
|
||||
var modules;
|
||||
const width = 50;
|
||||
const height = 100;
|
||||
|
||||
beforeEach(function() {
|
||||
getDependencies = jest.genMockFn();
|
||||
|
@ -125,12 +108,10 @@ describe('Bundler', function() {
|
|||
}),
|
||||
];
|
||||
|
||||
const mainModule = new Module({file: '/root/foo'});
|
||||
getDependencies.mockImpl(function() {
|
||||
return Promise.resolve({
|
||||
mainModuleId: 'foo',
|
||||
dependencies: modules,
|
||||
getMainModule: () => mainModule,
|
||||
dependencies: modules
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -151,13 +132,12 @@ describe('Bundler', function() {
|
|||
wrapModule.mockImpl(function(response, module, code) {
|
||||
return module.getName().then(name => ({
|
||||
name,
|
||||
id: name,
|
||||
code: 'lol ' + code + ' lol'
|
||||
}));
|
||||
});
|
||||
|
||||
sizeOf.mockImpl(function(path, cb) {
|
||||
cb(null, { width, height });
|
||||
cb(null, { width: 50, height: 100 });
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -207,8 +187,8 @@ describe('Bundler', function() {
|
|||
__packager_asset: true,
|
||||
fileSystemLocation: '/root/img',
|
||||
httpServerLocation: '/assets/img',
|
||||
width,
|
||||
height,
|
||||
width: 25,
|
||||
height: 50,
|
||||
scales: [1, 2, 3],
|
||||
files: [
|
||||
'/root/img/img.png',
|
||||
|
|
|
@ -102,8 +102,6 @@ class Bundler {
|
|||
mtime = '';
|
||||
}
|
||||
|
||||
this._getModuleId = createModuleIdGetter();
|
||||
|
||||
this._cache = new Cache({
|
||||
resetCache: opts.resetCache,
|
||||
cacheKey: [
|
||||
|
@ -124,7 +122,6 @@ class Bundler {
|
|||
fileWatcher: opts.fileWatcher,
|
||||
assetExts: opts.assetExts,
|
||||
cache: this._cache,
|
||||
getModuleId: this._getModuleId,
|
||||
});
|
||||
|
||||
this._bundlesLayout = new BundlesLayout({
|
||||
|
@ -190,19 +187,9 @@ class Bundler {
|
|||
const findEventId = Activity.startEvent('find dependencies');
|
||||
let transformEventId;
|
||||
|
||||
if (isDev) {
|
||||
// `require` calls int the require polyfill itself are not analyzed and
|
||||
// replaced so that they use numeric module IDs. Therefore, we include
|
||||
// the Systrace module before any other module, and it will set itself
|
||||
// as property on the require function.
|
||||
// TODO(davidaurelio) Scan polyfills for dependencies, too (t9759686)
|
||||
runBeforeMainModule = ['Systrace'].concat(runBeforeMainModule);
|
||||
}
|
||||
|
||||
const modulesByName = Object.create(null);
|
||||
return this.getDependencies(entryFile, isDev, platform).then((response) => {
|
||||
Activity.endEvent(findEventId);
|
||||
bundle.setMainModuleId(this._getModuleId(response.getMainModule()));
|
||||
bundle.setMainModuleId(response.mainModuleId);
|
||||
transformEventId = Activity.startEvent('transform');
|
||||
|
||||
const moduleSystemDeps = includeSystemDependencies
|
||||
|
@ -238,11 +225,6 @@ class Bundler {
|
|||
platform,
|
||||
hot,
|
||||
).then(transformed => {
|
||||
return module.getName().then(name => {
|
||||
modulesByName[name] = module;
|
||||
return transformed;
|
||||
});
|
||||
}).then(transformed => {
|
||||
if (bar) {
|
||||
bar.tick();
|
||||
}
|
||||
|
@ -266,11 +248,7 @@ class Bundler {
|
|||
));
|
||||
}).then(() => {
|
||||
Activity.endEvent(transformEventId);
|
||||
const runBeforeIds = runBeforeMainModule
|
||||
.map(name => modulesByName[name])
|
||||
.filter(Boolean)
|
||||
.map(this._getModuleId, this);
|
||||
bundle.finalize({runBeforeMainModule: runBeforeIds, runMainModule});
|
||||
bundle.finalize({runBeforeMainModule, runMainModule});
|
||||
return bundle;
|
||||
});
|
||||
}
|
||||
|
@ -484,7 +462,8 @@ class Bundler {
|
|||
type: assetData.type,
|
||||
};
|
||||
|
||||
const code = module.getCode(asset);
|
||||
const ASSET_TEMPLATE = 'module.exports = require("AssetRegistry").registerAsset(%json);';
|
||||
const code = ASSET_TEMPLATE.replace('%json', JSON.stringify(asset));
|
||||
|
||||
return {asset, code};
|
||||
});
|
||||
|
@ -543,21 +522,12 @@ function verifyRootExists(root) {
|
|||
assert(fs.statSync(root).isDirectory(), 'Root has to be a valid directory');
|
||||
}
|
||||
|
||||
class DummyCache {
|
||||
get(filepath, field, loaderCb) {
|
||||
return loaderCb();
|
||||
}
|
||||
|
||||
function createModuleIdGetter() {
|
||||
const fileToIdMap = Object.create(null);
|
||||
let nextId = 0;
|
||||
return (
|
||||
({path}) => {
|
||||
if (!(path in fileToIdMap)) {
|
||||
// can't be a number for now, since we also replace in import / export
|
||||
// we can change that when we eventually change to analyzing dependencies
|
||||
// on transformed modules
|
||||
fileToIdMap[path] = String(nextId++);
|
||||
}
|
||||
return fileToIdMap[path];
|
||||
}
|
||||
);
|
||||
end(){}
|
||||
invalidate(filepath){}
|
||||
}
|
||||
|
||||
module.exports = Bundler;
|
||||
|
|
|
@ -55,7 +55,6 @@ describe('BundlesLayout', () => {
|
|||
cache: new Cache(),
|
||||
assetExts: ['js', 'png'],
|
||||
assetRoots: ['/root'],
|
||||
getModuleId: () => {},
|
||||
});
|
||||
|
||||
return new BundlesLayout({
|
||||
|
|
|
@ -18,19 +18,13 @@ class AssetModule extends Module {
|
|||
}
|
||||
|
||||
getDependencies() {
|
||||
return Promise.resolve(['AssetRegistry']);
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
getAsyncDependencies() {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
getCode(assetData) {
|
||||
return `module.exports = require('AssetRegistry').registerAsset(${
|
||||
JSON.stringify(assetData)
|
||||
});`;
|
||||
}
|
||||
|
||||
read() {
|
||||
return Promise.resolve({});
|
||||
}
|
||||
|
|
|
@ -39,11 +39,6 @@ class ResolutionResponse {
|
|||
});
|
||||
}
|
||||
|
||||
getMainModule() {
|
||||
this._assertFinalized();
|
||||
return this._mainModule;
|
||||
}
|
||||
|
||||
pushDependency(module) {
|
||||
this._assertNotFinalized();
|
||||
if (this.dependencies.length === 0) {
|
||||
|
|
|
@ -374,7 +374,7 @@ describe('DependencyGraph', function() {
|
|||
{
|
||||
id: 'rootPackage/imgs/a.png',
|
||||
path: '/root/imgs/a.png',
|
||||
dependencies: ['AssetRegistry'],
|
||||
dependencies: [],
|
||||
isAsset: true,
|
||||
resolution: 1,
|
||||
isAsset_DEPRECATED: false,
|
||||
|
@ -434,7 +434,7 @@ describe('DependencyGraph', function() {
|
|||
id: 'rootPackage/imgs/a.png',
|
||||
path: '/root/imgs/a@1.5x.png',
|
||||
resolution: 1.5,
|
||||
dependencies: ['AssetRegistry'],
|
||||
dependencies: [],
|
||||
isAsset: true,
|
||||
isAsset_DEPRECATED: false,
|
||||
isJSON: false,
|
||||
|
@ -444,7 +444,7 @@ describe('DependencyGraph', function() {
|
|||
id: 'rootPackage/imgs/b.png',
|
||||
path: '/root/imgs/b@.7x.png',
|
||||
resolution: 0.7,
|
||||
dependencies: ['AssetRegistry'],
|
||||
dependencies: [],
|
||||
isAsset: true,
|
||||
isAsset_DEPRECATED: false,
|
||||
isJSON: false,
|
||||
|
@ -454,7 +454,7 @@ describe('DependencyGraph', function() {
|
|||
id: 'rootPackage/imgs/c.png',
|
||||
path: '/root/imgs/c.png',
|
||||
resolution: 1,
|
||||
dependencies: ['AssetRegistry'],
|
||||
dependencies: [],
|
||||
isAsset: true,
|
||||
isAsset_DEPRECATED: false,
|
||||
isJSON: false,
|
||||
|
@ -514,7 +514,7 @@ describe('DependencyGraph', function() {
|
|||
id: 'rootPackage/imgs/a.png',
|
||||
path: '/root/imgs/a@1.5x.ios.png',
|
||||
resolution: 1.5,
|
||||
dependencies: ['AssetRegistry'],
|
||||
dependencies: [],
|
||||
isAsset: true,
|
||||
isAsset_DEPRECATED: false,
|
||||
isJSON: false,
|
||||
|
@ -524,7 +524,7 @@ describe('DependencyGraph', function() {
|
|||
id: 'rootPackage/imgs/b.png',
|
||||
path: '/root/imgs/b@.7x.ios.png',
|
||||
resolution: 0.7,
|
||||
dependencies: ['AssetRegistry'],
|
||||
dependencies: [],
|
||||
isAsset: true,
|
||||
isAsset_DEPRECATED: false,
|
||||
isJSON: false,
|
||||
|
@ -534,7 +534,7 @@ describe('DependencyGraph', function() {
|
|||
id: 'rootPackage/imgs/c.png',
|
||||
path: '/root/imgs/c.ios.png',
|
||||
resolution: 1,
|
||||
dependencies: ['AssetRegistry'],
|
||||
dependencies: [],
|
||||
isAsset: true,
|
||||
isAsset_DEPRECATED: false,
|
||||
isJSON: false,
|
||||
|
@ -585,7 +585,7 @@ describe('DependencyGraph', function() {
|
|||
{
|
||||
id: 'rootPackage/imgs/a.png',
|
||||
path: '/root/imgs/a.png',
|
||||
dependencies: ['AssetRegistry'],
|
||||
dependencies: [],
|
||||
isAsset: true,
|
||||
resolution: 1,
|
||||
isAsset_DEPRECATED: false,
|
||||
|
@ -3367,7 +3367,7 @@ describe('DependencyGraph', function() {
|
|||
{
|
||||
id: 'aPackage/foo.png',
|
||||
path: '/root/foo.png',
|
||||
dependencies: ['AssetRegistry'],
|
||||
dependencies: [],
|
||||
isAsset: true,
|
||||
resolution: 1,
|
||||
isAsset_DEPRECATED: false,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
exports.IMPORT_RE = /(\bimport\s*(?:[\s{][^'"]+[\s}]from\s*)??)(['"])([^'"]+)\2()/g;
|
||||
exports.EXPORT_RE = /(\bexport\s*(?:[\s{][^'"]+[\s}]from\s*)??)(['"])([^'"]+)\2()/g;
|
||||
exports.REQUIRE_RE = /(\brequire\s*?\(\s*?)(['"])([^'"]+)\2(\s*?\))/g;
|
||||
exports.SYSTEM_IMPORT_RE = /(\bSystem\.import\s*?\(\s*?)(['"])([^'"]+)\2(\s*?\))/g;
|
||||
exports.IMPORT_RE = /(\bimport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g;
|
||||
exports.EXPORT_RE = /(\bexport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g;
|
||||
exports.REQUIRE_RE = /(\brequire\s*?\(\s*?)(['"])([^'"]+)(\2\s*?\))/g;
|
||||
exports.SYSTEM_IMPORT_RE = /(\bSystem\.import\s*?\(\s*?)(['"])([^'"]+)(\2\s*?\))/g;
|
||||
|
|
|
@ -35,12 +35,6 @@ describe('Resolver', function() {
|
|||
});
|
||||
});
|
||||
|
||||
const modulesWithIds = [];
|
||||
function getModuleId(module) {
|
||||
const index = modulesWithIds.indexOf(module);
|
||||
return String(index !== -1 ? index + 1 : modulesWithIds.push(module));
|
||||
}
|
||||
|
||||
class ResolutionResponseMock {
|
||||
constructor({dependencies, mainModuleId, asyncDependencies}) {
|
||||
this.dependencies = dependencies;
|
||||
|
@ -79,7 +73,6 @@ describe('Resolver', function() {
|
|||
|
||||
var depResolver = new Resolver({
|
||||
projectRoot: '/root',
|
||||
getModuleId,
|
||||
});
|
||||
|
||||
DependencyGraph.prototype.getDependencies.mockImpl(function() {
|
||||
|
@ -167,7 +160,6 @@ describe('Resolver', function() {
|
|||
|
||||
var depResolver = new Resolver({
|
||||
projectRoot: '/root',
|
||||
getModuleId,
|
||||
});
|
||||
|
||||
DependencyGraph.prototype.getDependencies.mockImpl(function() {
|
||||
|
@ -195,7 +187,6 @@ describe('Resolver', function() {
|
|||
var depResolver = new Resolver({
|
||||
projectRoot: '/root',
|
||||
polyfillModuleNames: ['some module'],
|
||||
getModuleId,
|
||||
});
|
||||
|
||||
DependencyGraph.prototype.getDependencies.mockImpl(function() {
|
||||
|
@ -232,13 +223,12 @@ describe('Resolver', function() {
|
|||
pit('should resolve modules', function() {
|
||||
var depResolver = new Resolver({
|
||||
projectRoot: '/root',
|
||||
getModuleId,
|
||||
});
|
||||
|
||||
const magicJoiner = '\n\n\n';
|
||||
var dependencies = ['x', 'y', 'z', 'a', 'b'];
|
||||
|
||||
/*eslint-disable */
|
||||
const testCases = [
|
||||
var code = [
|
||||
// single line import
|
||||
"import'x';",
|
||||
"import 'x';",
|
||||
|
@ -313,7 +303,6 @@ describe('Resolver', function() {
|
|||
'import * as All from "x";',
|
||||
'import { } from "x";',
|
||||
'import { Foo } from "x";',
|
||||
'import{Foo}from"x";',
|
||||
'import { Foo, } from "x";',
|
||||
'import { Foo as Bar } from "x";',
|
||||
'import { Foo as Bar, } from "x";',
|
||||
|
@ -439,7 +428,6 @@ describe('Resolver', function() {
|
|||
"export { } from 'x';",
|
||||
"export {Foo} from 'x';",
|
||||
"export { Foo } from 'x';",
|
||||
"export{Foo}from'x';",
|
||||
"export { Foo, } from 'x';",
|
||||
"export {Foo as Bar} from 'x';",
|
||||
"export { Foo as Bar } from 'x';",
|
||||
|
@ -625,9 +613,8 @@ describe('Resolver', function() {
|
|||
'require( \'z\' )',
|
||||
'require( "a")',
|
||||
'require("b" )',
|
||||
]
|
||||
].join('\n');
|
||||
/*eslint-disable */
|
||||
const code = testCases.join(magicJoiner);
|
||||
|
||||
const module = createModule('test module', ['x', 'y']);
|
||||
|
||||
|
@ -637,21 +624,11 @@ describe('Resolver', function() {
|
|||
asyncDependencies: [],
|
||||
});
|
||||
|
||||
const pairs = [
|
||||
['x', createModule('changed')],
|
||||
['y', createModule('Y')],
|
||||
];
|
||||
resolutionResponse.getResolvedDependencyPairs = () => pairs;
|
||||
|
||||
function makeExpected(code) {
|
||||
return pairs
|
||||
.reduce((code, [id, module]) =>
|
||||
code.replace(
|
||||
RegExp(`(['"])${id}\\1`),
|
||||
(_, quot) => `${quot}${getModuleId(module)}${quot} /* ${id} */`
|
||||
),
|
||||
code
|
||||
);
|
||||
resolutionResponse.getResolvedDependencyPairs = (module) => {
|
||||
return [
|
||||
['x', createModule('changed')],
|
||||
['y', createModule('Y')],
|
||||
];
|
||||
}
|
||||
|
||||
return depResolver.wrapModule(
|
||||
|
@ -660,20 +637,395 @@ describe('Resolver', function() {
|
|||
code
|
||||
).then(processedCode => {
|
||||
expect(processedCode.name).toEqual('test module');
|
||||
|
||||
// extract the converted code from the module wrapper
|
||||
const cases =
|
||||
processedCode.code
|
||||
.match(/__d\(.*?\{\s*([\s\S]*)\}/)[1] // match code in wrapper
|
||||
.replace(/\s+$/, '') // remove trailing whitespace
|
||||
.split(magicJoiner); // extract every tested case
|
||||
|
||||
testCases.forEach((inputCode, i) => {
|
||||
expect(cases[i]).toEqual(makeExpected(inputCode));
|
||||
if(cases[i]!==makeExpected(inputCode)) {
|
||||
console.log('FAIL %s: input(%s) expected(%s) actual(%s)', i, inputCode, makeExpected(inputCode), cases[i]);
|
||||
}
|
||||
});
|
||||
expect(processedCode.code).toEqual([
|
||||
'__d(\'test module\',function(global, require,' +
|
||||
' module, exports) { ' +
|
||||
// single line import
|
||||
"import'x';",
|
||||
"import 'changed';",
|
||||
"import 'changed' ;",
|
||||
"import Default from 'changed';",
|
||||
"import * as All from 'changed';",
|
||||
"import {} from 'changed';",
|
||||
"import { } from 'changed';",
|
||||
"import {Foo} from 'changed';",
|
||||
"import { Foo } from 'changed';",
|
||||
"import { Foo, } from 'changed';",
|
||||
"import {Foo as Bar} from 'changed';",
|
||||
"import { Foo as Bar } from 'changed';",
|
||||
"import { Foo as Bar, } from 'changed';",
|
||||
"import { Foo, Bar } from 'changed';",
|
||||
"import { Foo, Bar, } from 'changed';",
|
||||
"import { Foo as Bar, Baz } from 'changed';",
|
||||
"import { Foo as Bar, Baz, } from 'changed';",
|
||||
"import { Foo, Bar as Baz } from 'changed';",
|
||||
"import { Foo, Bar as Baz, } from 'changed';",
|
||||
"import { Foo as Bar, Baz as Qux } from 'changed';",
|
||||
"import { Foo as Bar, Baz as Qux, } from 'changed';",
|
||||
"import { Foo, Bar, Baz } from 'changed';",
|
||||
"import { Foo, Bar, Baz, } from 'changed';",
|
||||
"import { Foo as Bar, Baz, Qux } from 'changed';",
|
||||
"import { Foo as Bar, Baz, Qux, } from 'changed';",
|
||||
"import { Foo, Bar as Baz, Qux } from 'changed';",
|
||||
"import { Foo, Bar as Baz, Qux, } from 'changed';",
|
||||
"import { Foo, Bar, Baz as Qux } from 'changed';",
|
||||
"import { Foo, Bar, Baz as Qux, } from 'changed';",
|
||||
"import { Foo as Bar, Baz as Qux, Norf } from 'changed';",
|
||||
"import { Foo as Bar, Baz as Qux, Norf, } from 'changed';",
|
||||
"import { Foo as Bar, Baz, Qux as Norf } from 'changed';",
|
||||
"import { Foo as Bar, Baz, Qux as Norf, } from 'changed';",
|
||||
"import { Foo, Bar as Baz, Qux as Norf } from 'changed';",
|
||||
"import { Foo, Bar as Baz, Qux as Norf, } from 'changed';",
|
||||
"import { Foo as Bar, Baz as Qux, Norf as Enuf } from 'changed';",
|
||||
"import { Foo as Bar, Baz as Qux, Norf as Enuf, } from 'changed';",
|
||||
"import Default, * as All from 'changed';",
|
||||
"import Default, { } from 'changed';",
|
||||
"import Default, { Foo } from 'changed';",
|
||||
"import Default, { Foo, } from 'changed';",
|
||||
"import Default, { Foo as Bar } from 'changed';",
|
||||
"import Default, { Foo as Bar, } from 'changed';",
|
||||
"import Default, { Foo, Bar } from 'changed';",
|
||||
"import Default, { Foo, Bar, } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz, } from 'changed';",
|
||||
"import Default, { Foo, Bar as Baz } from 'changed';",
|
||||
"import Default, { Foo, Bar as Baz, } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz as Qux } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz as Qux, } from 'changed';",
|
||||
"import Default, { Foo, Bar, Baz } from 'changed';",
|
||||
"import Default, { Foo, Bar, Baz, } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz, Qux } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz, Qux, } from 'changed';",
|
||||
"import Default, { Foo, Bar as Baz, Qux } from 'changed';",
|
||||
"import Default, { Foo, Bar as Baz, Qux, } from 'changed';",
|
||||
"import Default, { Foo, Bar, Baz as Qux } from 'changed';",
|
||||
"import Default, { Foo, Bar, Baz as Qux, } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz as Qux, Norf } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz as Qux, Norf, } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz, Qux as Norf } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz, Qux as Norf, } from 'changed';",
|
||||
"import Default, { Foo, Bar as Baz, Qux as Norf } from 'changed';",
|
||||
"import Default, { Foo, Bar as Baz, Qux as Norf, } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz as Qux, Norf as NoMore } from 'changed';",
|
||||
"import Default, { Foo as Bar, Baz as Qux, Norf as NoMore, } from 'changed';",
|
||||
"import Default , { } from 'changed';",
|
||||
'import "changed";',
|
||||
'import Default from "changed";',
|
||||
'import * as All from "changed";',
|
||||
'import { } from "changed";',
|
||||
'import { Foo } from "changed";',
|
||||
'import { Foo, } from "changed";',
|
||||
'import { Foo as Bar } from "changed";',
|
||||
'import { Foo as Bar, } from "changed";',
|
||||
'import { Foo, Bar } from "changed";',
|
||||
'import { Foo, Bar, } from "changed";',
|
||||
'import { Foo as Bar, Baz } from "changed";',
|
||||
'import { Foo as Bar, Baz, } from "changed";',
|
||||
'import { Foo, Bar as Baz } from "changed";',
|
||||
'import { Foo, Bar as Baz, } from "changed";',
|
||||
'import { Foo as Bar, Baz as Qux } from "changed";',
|
||||
'import { Foo as Bar, Baz as Qux, } from "changed";',
|
||||
'import { Foo, Bar, Baz } from "changed";',
|
||||
'import { Foo, Bar, Baz, } from "changed";',
|
||||
'import { Foo as Bar, Baz, Qux } from "changed";',
|
||||
'import { Foo as Bar, Baz, Qux, } from "changed";',
|
||||
'import { Foo, Bar as Baz, Qux } from "changed";',
|
||||
'import { Foo, Bar as Baz, Qux, } from "changed";',
|
||||
'import { Foo, Bar, Baz as Qux } from "changed";',
|
||||
'import { Foo, Bar, Baz as Qux, } from "changed";',
|
||||
'import { Foo as Bar, Baz as Qux, Norf } from "changed";',
|
||||
'import { Foo as Bar, Baz as Qux, Norf, } from "changed";',
|
||||
'import { Foo as Bar, Baz, Qux as Norf } from "changed";',
|
||||
'import { Foo as Bar, Baz, Qux as Norf, } from "changed";',
|
||||
'import { Foo, Bar as Baz, Qux as Norf } from "changed";',
|
||||
'import { Foo, Bar as Baz, Qux as Norf, } from "changed";',
|
||||
'import { Foo as Bar, Baz as Qux, Norf as NoMore } from "changed";',
|
||||
'import { Foo as Bar, Baz as Qux, Norf as NoMore, } from "changed";',
|
||||
'import Default, * as All from "changed";',
|
||||
'import Default, { } from "changed";',
|
||||
'import Default, { Foo } from "changed";',
|
||||
'import Default, { Foo, } from "changed";',
|
||||
'import Default, { Foo as Bar } from "changed";',
|
||||
'import Default, { Foo as Bar, } from "changed";',
|
||||
'import Default, { Foo, Bar } from "changed";',
|
||||
'import Default, { Foo, Bar, } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz, } from "changed";',
|
||||
'import Default, { Foo, Bar as Baz } from "changed";',
|
||||
'import Default, { Foo, Bar as Baz, } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz as Qux } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz as Qux, } from "changed";',
|
||||
'import Default, { Foo, Bar, Baz } from "changed";',
|
||||
'import Default, { Foo, Bar, Baz, } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz, Qux } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz, Qux, } from "changed";',
|
||||
'import Default, { Foo, Bar as Baz, Qux } from "changed";',
|
||||
'import Default, { Foo, Bar as Baz, Qux, } from "changed";',
|
||||
'import Default, { Foo, Bar, Baz as Qux } from "changed";',
|
||||
'import Default, { Foo, Bar, Baz as Qux, } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz as Qux, Norf } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz as Qux, Norf, } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz, Qux as Norf } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz, Qux as Norf, } from "changed";',
|
||||
'import Default, { Foo, Bar as Baz, Qux as Norf } from "changed";',
|
||||
'import Default, { Foo, Bar as Baz, Qux as Norf, } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz as Qux, Norf as Enuf } from "changed";',
|
||||
'import Default, { Foo as Bar, Baz as Qux, Norf as Enuf, } from "changed";',
|
||||
'import Default from "Y";',
|
||||
'import * as All from \'z\';',
|
||||
// import with support for new lines
|
||||
"import { Foo,\n Bar }\n from 'changed';",
|
||||
"import { \nFoo,\nBar,\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz\n }\n from 'changed';",
|
||||
"import { \nFoo as Bar,\n Baz\n, }\n from 'changed';",
|
||||
"import { Foo,\n Bar as Baz\n }\n from 'changed';",
|
||||
"import { Foo,\n Bar as Baz,\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz as Qux\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz as Qux,\n }\n from 'changed';",
|
||||
"import { Foo,\n Bar,\n Baz }\n from 'changed';",
|
||||
"import { Foo,\n Bar,\n Baz,\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz,\n Qux\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz,\n Qux,\n }\n from 'changed';",
|
||||
"import { Foo,\n Bar as Baz,\n Qux\n }\n from 'changed';",
|
||||
"import { Foo,\n Bar as Baz,\n Qux,\n }\n from 'changed';",
|
||||
"import { Foo,\n Bar,\n Baz as Qux\n }\n from 'changed';",
|
||||
"import { Foo,\n Bar,\n Baz as Qux,\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz as Qux,\n Norf\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz as Qux,\n Norf,\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz,\n Qux as Norf\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz,\n Qux as Norf,\n }\n from 'changed';",
|
||||
"import { Foo,\n Bar as Baz,\n Qux as Norf\n }\n from 'changed';",
|
||||
"import { Foo,\n Bar as Baz,\n Qux as Norf,\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz as Qux,\n Norf as Enuf\n }\n from 'changed';",
|
||||
"import { Foo as Bar,\n Baz as Qux,\n Norf as Enuf,\n }\n from 'changed';",
|
||||
"import Default,\n * as All from 'changed';",
|
||||
"import Default,\n { } from 'changed';",
|
||||
"import Default,\n { Foo\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n Bar\n } from\n 'changed';",
|
||||
"import Default,\n { Foo,\n Bar,\n } from\n 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n Bar as Baz\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n Bar as Baz,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz as Qux\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz as Qux,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n Bar,\n Baz\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n Bar,\n Baz,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz,\n Qux\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz,\n Qux,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n Bar as Baz,\n Qux\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n Bar as Baz,\n Qux,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n Bar,\n Baz as Qux\n }\n from 'changed';",
|
||||
"import Default,\n { Foo,\n Bar,\n Baz as Qux,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz as Qux,\n Norf\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz as Qux,\n Norf,\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz,\n Qux as Norf }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz,\n Qux as Norf, }\n from 'changed';",
|
||||
"import Default,\n { Foo, Bar as Baz,\n Qux as Norf }\n from 'changed';",
|
||||
"import Default,\n { Foo, Bar as Baz,\n Qux as Norf, }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz as Qux,\n Norf as NoMore\n }\n from 'changed';",
|
||||
"import Default,\n { Foo as Bar,\n Baz as Qux,\n Norf as NoMore,\n }\n from 'changed';",
|
||||
"import Default\n , { } from 'changed';",
|
||||
// single line export
|
||||
"export'x';",
|
||||
"export 'changed';",
|
||||
"export 'changed' ;",
|
||||
"export Default from 'changed';",
|
||||
"export * as All from 'changed';",
|
||||
"export {} from 'changed';",
|
||||
"export { } from 'changed';",
|
||||
"export {Foo} from 'changed';",
|
||||
"export { Foo } from 'changed';",
|
||||
"export { Foo, } from 'changed';",
|
||||
"export {Foo as Bar} from 'changed';",
|
||||
"export { Foo as Bar } from 'changed';",
|
||||
"export { Foo as Bar, } from 'changed';",
|
||||
"export { Foo, Bar } from 'changed';",
|
||||
"export { Foo, Bar, } from 'changed';",
|
||||
"export { Foo as Bar, Baz } from 'changed';",
|
||||
"export { Foo as Bar, Baz, } from 'changed';",
|
||||
"export { Foo, Bar as Baz } from 'changed';",
|
||||
"export { Foo, Bar as Baz, } from 'changed';",
|
||||
"export { Foo as Bar, Baz as Qux } from 'changed';",
|
||||
"export { Foo as Bar, Baz as Qux, } from 'changed';",
|
||||
"export { Foo, Bar, Baz } from 'changed';",
|
||||
"export { Foo, Bar, Baz, } from 'changed';",
|
||||
"export { Foo as Bar, Baz, Qux } from 'changed';",
|
||||
"export { Foo as Bar, Baz, Qux, } from 'changed';",
|
||||
"export { Foo, Bar as Baz, Qux } from 'changed';",
|
||||
"export { Foo, Bar as Baz, Qux, } from 'changed';",
|
||||
"export { Foo, Bar, Baz as Qux } from 'changed';",
|
||||
"export { Foo, Bar, Baz as Qux, } from 'changed';",
|
||||
"export { Foo as Bar, Baz as Qux, Norf } from 'changed';",
|
||||
"export { Foo as Bar, Baz as Qux, Norf, } from 'changed';",
|
||||
"export { Foo as Bar, Baz, Qux as Norf } from 'changed';",
|
||||
"export { Foo as Bar, Baz, Qux as Norf, } from 'changed';",
|
||||
"export { Foo, Bar as Baz, Qux as Norf } from 'changed';",
|
||||
"export { Foo, Bar as Baz, Qux as Norf, } from 'changed';",
|
||||
"export { Foo as Bar, Baz as Qux, Norf as Enuf } from 'changed';",
|
||||
"export { Foo as Bar, Baz as Qux, Norf as Enuf, } from 'changed';",
|
||||
"export Default, * as All from 'changed';",
|
||||
"export Default, { } from 'changed';",
|
||||
"export Default, { Foo } from 'changed';",
|
||||
"export Default, { Foo, } from 'changed';",
|
||||
"export Default, { Foo as Bar } from 'changed';",
|
||||
"export Default, { Foo as Bar, } from 'changed';",
|
||||
"export Default, { Foo, Bar } from 'changed';",
|
||||
"export Default, { Foo, Bar, } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz, } from 'changed';",
|
||||
"export Default, { Foo, Bar as Baz } from 'changed';",
|
||||
"export Default, { Foo, Bar as Baz, } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz as Qux } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz as Qux, } from 'changed';",
|
||||
"export Default, { Foo, Bar, Baz } from 'changed';",
|
||||
"export Default, { Foo, Bar, Baz, } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz, Qux } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz, Qux, } from 'changed';",
|
||||
"export Default, { Foo, Bar as Baz, Qux } from 'changed';",
|
||||
"export Default, { Foo, Bar as Baz, Qux, } from 'changed';",
|
||||
"export Default, { Foo, Bar, Baz as Qux } from 'changed';",
|
||||
"export Default, { Foo, Bar, Baz as Qux, } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz as Qux, Norf } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz as Qux, Norf, } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz, Qux as Norf } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz, Qux as Norf, } from 'changed';",
|
||||
"export Default, { Foo, Bar as Baz, Qux as Norf } from 'changed';",
|
||||
"export Default, { Foo, Bar as Baz, Qux as Norf, } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz as Qux, Norf as NoMore } from 'changed';",
|
||||
"export Default, { Foo as Bar, Baz as Qux, Norf as NoMore, } from 'changed';",
|
||||
"export Default , { } from 'changed';",
|
||||
'export "changed";',
|
||||
'export Default from "changed";',
|
||||
'export * as All from "changed";',
|
||||
'export { } from "changed";',
|
||||
'export { Foo } from "changed";',
|
||||
'export { Foo, } from "changed";',
|
||||
'export { Foo as Bar } from "changed";',
|
||||
'export { Foo as Bar, } from "changed";',
|
||||
'export { Foo, Bar } from "changed";',
|
||||
'export { Foo, Bar, } from "changed";',
|
||||
'export { Foo as Bar, Baz } from "changed";',
|
||||
'export { Foo as Bar, Baz, } from "changed";',
|
||||
'export { Foo, Bar as Baz } from "changed";',
|
||||
'export { Foo, Bar as Baz, } from "changed";',
|
||||
'export { Foo as Bar, Baz as Qux } from "changed";',
|
||||
'export { Foo as Bar, Baz as Qux, } from "changed";',
|
||||
'export { Foo, Bar, Baz } from "changed";',
|
||||
'export { Foo, Bar, Baz, } from "changed";',
|
||||
'export { Foo as Bar, Baz, Qux } from "changed";',
|
||||
'export { Foo as Bar, Baz, Qux, } from "changed";',
|
||||
'export { Foo, Bar as Baz, Qux } from "changed";',
|
||||
'export { Foo, Bar as Baz, Qux, } from "changed";',
|
||||
'export { Foo, Bar, Baz as Qux } from "changed";',
|
||||
'export { Foo, Bar, Baz as Qux, } from "changed";',
|
||||
'export { Foo as Bar, Baz as Qux, Norf } from "changed";',
|
||||
'export { Foo as Bar, Baz as Qux, Norf, } from "changed";',
|
||||
'export { Foo as Bar, Baz, Qux as Norf } from "changed";',
|
||||
'export { Foo as Bar, Baz, Qux as Norf, } from "changed";',
|
||||
'export { Foo, Bar as Baz, Qux as Norf } from "changed";',
|
||||
'export { Foo, Bar as Baz, Qux as Norf, } from "changed";',
|
||||
'export { Foo as Bar, Baz as Qux, Norf as NoMore } from "changed";',
|
||||
'export { Foo as Bar, Baz as Qux, Norf as NoMore, } from "changed";',
|
||||
'export Default, * as All from "changed";',
|
||||
'export Default, { } from "changed";',
|
||||
'export Default, { Foo } from "changed";',
|
||||
'export Default, { Foo, } from "changed";',
|
||||
'export Default, { Foo as Bar } from "changed";',
|
||||
'export Default, { Foo as Bar, } from "changed";',
|
||||
'export Default, { Foo, Bar } from "changed";',
|
||||
'export Default, { Foo, Bar, } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz, } from "changed";',
|
||||
'export Default, { Foo, Bar as Baz } from "changed";',
|
||||
'export Default, { Foo, Bar as Baz, } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz as Qux } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz as Qux, } from "changed";',
|
||||
'export Default, { Foo, Bar, Baz } from "changed";',
|
||||
'export Default, { Foo, Bar, Baz, } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz, Qux } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz, Qux, } from "changed";',
|
||||
'export Default, { Foo, Bar as Baz, Qux } from "changed";',
|
||||
'export Default, { Foo, Bar as Baz, Qux, } from "changed";',
|
||||
'export Default, { Foo, Bar, Baz as Qux } from "changed";',
|
||||
'export Default, { Foo, Bar, Baz as Qux, } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz as Qux, Norf } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz as Qux, Norf, } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz, Qux as Norf } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz, Qux as Norf, } from "changed";',
|
||||
'export Default, { Foo, Bar as Baz, Qux as Norf } from "changed";',
|
||||
'export Default, { Foo, Bar as Baz, Qux as Norf, } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz as Qux, Norf as Enuf } from "changed";',
|
||||
'export Default, { Foo as Bar, Baz as Qux, Norf as Enuf, } from "changed";',
|
||||
'export Default from "Y";',
|
||||
'export * as All from \'z\';',
|
||||
// export with support for new lines
|
||||
"export { Foo,\n Bar }\n from 'changed';",
|
||||
"export { \nFoo,\nBar,\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz\n }\n from 'changed';",
|
||||
"export { \nFoo as Bar,\n Baz\n, }\n from 'changed';",
|
||||
"export { Foo,\n Bar as Baz\n }\n from 'changed';",
|
||||
"export { Foo,\n Bar as Baz,\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz as Qux\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz as Qux,\n }\n from 'changed';",
|
||||
"export { Foo,\n Bar,\n Baz }\n from 'changed';",
|
||||
"export { Foo,\n Bar,\n Baz,\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz,\n Qux\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz,\n Qux,\n }\n from 'changed';",
|
||||
"export { Foo,\n Bar as Baz,\n Qux\n }\n from 'changed';",
|
||||
"export { Foo,\n Bar as Baz,\n Qux,\n }\n from 'changed';",
|
||||
"export { Foo,\n Bar,\n Baz as Qux\n }\n from 'changed';",
|
||||
"export { Foo,\n Bar,\n Baz as Qux,\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz as Qux,\n Norf\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz as Qux,\n Norf,\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz,\n Qux as Norf\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz,\n Qux as Norf,\n }\n from 'changed';",
|
||||
"export { Foo,\n Bar as Baz,\n Qux as Norf\n }\n from 'changed';",
|
||||
"export { Foo,\n Bar as Baz,\n Qux as Norf,\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz as Qux,\n Norf as Enuf\n }\n from 'changed';",
|
||||
"export { Foo as Bar,\n Baz as Qux,\n Norf as Enuf,\n }\n from 'changed';",
|
||||
"export Default,\n * as All from 'changed';",
|
||||
"export Default,\n { } from 'changed';",
|
||||
"export Default,\n { Foo\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n Bar\n } from\n 'changed';",
|
||||
"export Default,\n { Foo,\n Bar,\n } from\n 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n Bar as Baz\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n Bar as Baz,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz as Qux\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz as Qux,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n Bar,\n Baz\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n Bar,\n Baz,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz,\n Qux\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz,\n Qux,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n Bar as Baz,\n Qux\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n Bar as Baz,\n Qux,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n Bar,\n Baz as Qux\n }\n from 'changed';",
|
||||
"export Default,\n { Foo,\n Bar,\n Baz as Qux,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz as Qux,\n Norf\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz as Qux,\n Norf,\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz,\n Qux as Norf }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz,\n Qux as Norf, }\n from 'changed';",
|
||||
"export Default,\n { Foo, Bar as Baz,\n Qux as Norf }\n from 'changed';",
|
||||
"export Default,\n { Foo, Bar as Baz,\n Qux as Norf, }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz as Qux,\n Norf as NoMore\n }\n from 'changed';",
|
||||
"export Default,\n { Foo as Bar,\n Baz as Qux,\n Norf as NoMore,\n }\n from 'changed';",
|
||||
"export Default\n , { } from 'changed';",
|
||||
// require
|
||||
'require("changed")',
|
||||
'require("Y")',
|
||||
'require( \'z\' )',
|
||||
'require( "a")',
|
||||
'require("b" )',
|
||||
'});',
|
||||
].join('\n'));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -49,10 +49,6 @@ const validateOpts = declareOpts({
|
|||
type: 'object',
|
||||
required: true,
|
||||
},
|
||||
getModuleId: {
|
||||
type: 'function',
|
||||
required: true,
|
||||
}
|
||||
});
|
||||
|
||||
const getDependenciesValidateOpts = declareOpts({
|
||||
|
@ -102,7 +98,6 @@ class Resolver {
|
|||
shouldThrowOnUnresolvedErrors: (_, platform) => platform === 'ios',
|
||||
});
|
||||
|
||||
this._getModuleId = options.getModuleId;
|
||||
this._polyfillModuleNames = opts.polyfillModuleNames || [];
|
||||
}
|
||||
|
||||
|
@ -182,32 +177,36 @@ class Resolver {
|
|||
}
|
||||
|
||||
const resolvedDeps = Object.create(null);
|
||||
const resolvedDepsArr = [];
|
||||
|
||||
return Promise.all(
|
||||
resolutionResponse.getResolvedDependencyPairs(module).map(
|
||||
([depName, depModule]) => {
|
||||
if (depModule) {
|
||||
resolvedDeps[depName] = this._getModuleId(depModule);
|
||||
return depModule.getName().then(name => {
|
||||
resolvedDeps[depName] = name;
|
||||
resolvedDepsArr.push(name);
|
||||
});
|
||||
}
|
||||
}
|
||||
)
|
||||
).then(() => {
|
||||
const replaceModuleId = (codeMatch, pre, quot, depName, post = '') => {
|
||||
if (depName in resolvedDeps) {
|
||||
const replacement = `${quot}${resolvedDeps[depName]}${quot}`;
|
||||
return `${pre}${replacement} /* ${depName} */${post}`;
|
||||
const relativizeCode = (codeMatch, pre, quot, depName, post) => {
|
||||
const depId = resolvedDeps[depName];
|
||||
if (depId) {
|
||||
return pre + quot + depId + post;
|
||||
} else {
|
||||
return codeMatch;
|
||||
}
|
||||
};
|
||||
|
||||
code = code
|
||||
.replace(replacePatterns.IMPORT_RE, replaceModuleId)
|
||||
.replace(replacePatterns.EXPORT_RE, replaceModuleId)
|
||||
.replace(replacePatterns.REQUIRE_RE, replaceModuleId);
|
||||
.replace(replacePatterns.IMPORT_RE, relativizeCode)
|
||||
.replace(replacePatterns.EXPORT_RE, relativizeCode)
|
||||
.replace(replacePatterns.REQUIRE_RE, relativizeCode);
|
||||
|
||||
return module.getName().then(name => {
|
||||
return {name, code, id: this._getModuleId(module)};
|
||||
return {name, code};
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -221,8 +220,8 @@ class Resolver {
|
|||
}
|
||||
|
||||
return this.resolveRequires(resolutionResponse, module, code).then(
|
||||
({name, code, id}) => {
|
||||
return {id, name, code: defineModuleCode(id, code, name)};
|
||||
({name, code}) => {
|
||||
return {name, code: defineModuleCode(name, code)};
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -232,10 +231,10 @@ class Resolver {
|
|||
|
||||
}
|
||||
|
||||
function defineModuleCode(moduleId, code, verboseName = '') {
|
||||
function defineModuleCode(moduleName, code) {
|
||||
return [
|
||||
`__d(`,
|
||||
`${JSON.stringify(moduleId)} /* ${verboseName} */ ,`,
|
||||
`'${moduleName}',`,
|
||||
'function(global, require, module, exports) {',
|
||||
` ${code}`,
|
||||
'\n});',
|
||||
|
|
|
@ -59,29 +59,18 @@ function requireImpl(id) {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
// `require` calls int the require polyfill itself are not analyzed and
|
||||
// replaced so that they use numeric module IDs.
|
||||
// The systrace module will expose itself on the require function so that
|
||||
// it can be used here.
|
||||
// TODO(davidaurelio) Scan polyfills for dependencies, too (t9759686)
|
||||
const {Systrace} = require;
|
||||
try {
|
||||
// We must optimistically mark mod as initialized before running the factory to keep any
|
||||
// require cycles inside the factory from causing an infinite require loop.
|
||||
mod.isInitialized = true;
|
||||
|
||||
if (__DEV__) {
|
||||
Systrace.beginEvent('JS_require_' + id);
|
||||
}
|
||||
__DEV__ && Systrace().beginEvent('JS_require_' + id);
|
||||
|
||||
// keep args in sync with with defineModuleCode in
|
||||
// packager/react-packager/src/Resolver/index.js
|
||||
mod.factory.call(global, global, require, mod.module, mod.module.exports);
|
||||
|
||||
if (__DEV__) {
|
||||
Systrace.endEvent();
|
||||
}
|
||||
__DEV__ && Systrace().endEvent();
|
||||
} catch (e) {
|
||||
mod.hasError = true;
|
||||
mod.isInitialized = false;
|
||||
|
@ -91,9 +80,15 @@ function requireImpl(id) {
|
|||
return mod.module.exports;
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
require.Systrace = { beginEvent: () => {}, endEvent: () => {} };
|
||||
}
|
||||
const Systrace = __DEV__ && (() => {
|
||||
var _Systrace;
|
||||
try {
|
||||
_Systrace = require('Systrace');
|
||||
} catch (e) {}
|
||||
|
||||
return _Systrace && _Systrace.beginEvent ?
|
||||
_Systrace : { beginEvent: () => {}, endEvent: () => {} };
|
||||
});
|
||||
|
||||
global.__d = define;
|
||||
global.require = require;
|
||||
|
|
Loading…
Reference in New Issue