Convert UMD to use new implementation of module logic.
This commit is contained in:
parent
47a254025a
commit
95e08b6d2a
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
"rulers": [
|
"rulers": [
|
||||||
110
|
80
|
||||||
],
|
],
|
||||||
|
|
||||||
// Set to false to disable detection of tabs vs. spaces on load
|
// Set to false to disable detection of tabs vs. spaces on load
|
||||||
|
|||||||
3
packages/babel-helper-modules/.npmignore
Normal file
3
packages/babel-helper-modules/.npmignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
src
|
||||||
|
test
|
||||||
|
*.log
|
||||||
5
packages/babel-helper-modules/README.md
Normal file
5
packages/babel-helper-modules/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# babel-helper-modules
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
TODO
|
||||||
15
packages/babel-helper-modules/package.json
Normal file
15
packages/babel-helper-modules/package.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "babel-helper-modules",
|
||||||
|
"version": "7.0.0-beta.0",
|
||||||
|
"description": "Babel helper functions for implementing ES6 module transformations",
|
||||||
|
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
||||||
|
"homepage": "https://babeljs.io/",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-modules",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"dependencies": {
|
||||||
|
"babel-template": "7.0.0-beta.0",
|
||||||
|
"babel-types": "7.0.0-beta.0",
|
||||||
|
"lodash": "^4.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
302
packages/babel-helper-modules/src/index.js
Normal file
302
packages/babel-helper-modules/src/index.js
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
import * as t from "babel-types";
|
||||||
|
import template from "babel-template";
|
||||||
|
import chunk from "lodash/chunk";
|
||||||
|
|
||||||
|
import rewriteThis from "./rewrite-this";
|
||||||
|
import rewriteLiveReferences from "./rewrite-live-references";
|
||||||
|
import normalizeAndLoadModuleMetadata, {
|
||||||
|
hasExports,
|
||||||
|
isSideEffectImport,
|
||||||
|
} from "./normalize-and-load-metadata";
|
||||||
|
|
||||||
|
export { hasExports };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform all of the generic ES6 module rewriting needed to handle initial
|
||||||
|
* module processing. This function will rewrite the majority of the given
|
||||||
|
* program to reference the modules described by the returned metadata,
|
||||||
|
* and returns a list of statements for use when initializing the module.
|
||||||
|
*/
|
||||||
|
export function rewriteModuleStatementsAndPrepareHeader(
|
||||||
|
path: NodePath,
|
||||||
|
{ exportName, strict, allowTopLevelThis, strictMode, loose, noInterop },
|
||||||
|
) {
|
||||||
|
const meta = normalizeAndLoadModuleMetadata(path, exportName, {
|
||||||
|
strict,
|
||||||
|
noInterop,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!allowTopLevelThis) {
|
||||||
|
rewriteThis(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
rewriteLiveReferences(path, meta);
|
||||||
|
|
||||||
|
if (strictMode !== false && strict !== false) {
|
||||||
|
const hasStrict = path.node.directives.some(directive => {
|
||||||
|
return directive.value.value === "use strict";
|
||||||
|
});
|
||||||
|
if (!hasStrict) {
|
||||||
|
path.unshiftContainer(
|
||||||
|
"directives",
|
||||||
|
t.directive(t.directiveLiteral("use strict")),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const headers = [];
|
||||||
|
if (hasExports(meta) && !strict) {
|
||||||
|
headers.push(buildESModuleHeader(meta, loose /* enumerable */));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create all of the statically known named exports.
|
||||||
|
headers.push(...buildExportInitializationStatements(path, meta));
|
||||||
|
|
||||||
|
return { meta, headers };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Break down the module metadata into a simple array that contains the
|
||||||
|
* fields generally needed for compiling ES6 module support.
|
||||||
|
*/
|
||||||
|
export function getSourceMetadataArray(meta: ModuleMetadata) {
|
||||||
|
const lastNonSideEffectBlock = Array.from(
|
||||||
|
meta.source,
|
||||||
|
).reduceRight((acc, [source, metadata]) => {
|
||||||
|
if (acc !== null) return acc;
|
||||||
|
|
||||||
|
if (isSideEffectImport(metadata)) return null;
|
||||||
|
return source;
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
let inSideEffectBlock = lastNonSideEffectBlock === null;
|
||||||
|
|
||||||
|
const items = [];
|
||||||
|
for (const [source, metadata] of meta.source) {
|
||||||
|
const isSideEffect = isSideEffectImport(metadata);
|
||||||
|
|
||||||
|
items.push([source, metadata, isSideEffect, inSideEffectBlock]);
|
||||||
|
|
||||||
|
if (source === lastNonSideEffectBlock) inSideEffectBlock = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag a set of statements as hoisted above all else so that module init
|
||||||
|
* statements all run before user code.
|
||||||
|
*/
|
||||||
|
export function ensureStatementsHoisted(statements) {
|
||||||
|
// Force all of the header fields to be at the top of the file.
|
||||||
|
statements.forEach(header => {
|
||||||
|
header._blockHoist = 3;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an expression for a standard import object, like "require('foo')",
|
||||||
|
* wrap it in a call to the interop helpers based on the type.
|
||||||
|
*/
|
||||||
|
export function wrapInterop(
|
||||||
|
programPath: NodePath,
|
||||||
|
expr: Node,
|
||||||
|
type: InteropType,
|
||||||
|
): Node {
|
||||||
|
if (type === "none") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let helper;
|
||||||
|
if (type === "default") {
|
||||||
|
helper = "interopRequireDefault";
|
||||||
|
} else if (type === "namespace") {
|
||||||
|
helper = "interopRequireWildcard";
|
||||||
|
} else {
|
||||||
|
throw new Error(`Unknown interop: ${type}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return t.callExpression(programPath.hub.file.addHelper(helper), [expr]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildNamespaceInit = template(`
|
||||||
|
var NAME = SOURCE;
|
||||||
|
`);
|
||||||
|
|
||||||
|
const buildReexportNamespace = template(`
|
||||||
|
EXPORTS.NAME = NAMESPACE;
|
||||||
|
`);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the runtime initialization statements for a given requested source.
|
||||||
|
* These will initialize all of the runtime import/export logic that
|
||||||
|
* can't be handled statically by the statements created by
|
||||||
|
* buildExportInitializationStatements().
|
||||||
|
*/
|
||||||
|
export function buildNamespaceInitStatements(
|
||||||
|
metadata: ModuleMetadata,
|
||||||
|
sourceMetadata: SourceModuleMetadata,
|
||||||
|
) {
|
||||||
|
const statements = [];
|
||||||
|
|
||||||
|
for (const localName of sourceMetadata.importsNamespace) {
|
||||||
|
if (localName === sourceMetadata.name) continue;
|
||||||
|
|
||||||
|
// Create and assign binding to namespace object
|
||||||
|
statements.push(
|
||||||
|
buildNamespaceInit({
|
||||||
|
NAME: t.identifier(localName),
|
||||||
|
SOURCE: t.identifier(sourceMetadata.name),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (const exportName of sourceMetadata.reexportNamespace) {
|
||||||
|
// Assign export to namespace object.
|
||||||
|
statements.push(
|
||||||
|
buildReexportNamespace({
|
||||||
|
EXPORTS: t.identifier(metadata.exportName),
|
||||||
|
NAME: t.identifier(exportName),
|
||||||
|
NAMESPACE: t.identifier(sourceMetadata.name),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (sourceMetadata.reexportAll) {
|
||||||
|
const statement = buildNamespaceReexport(metadata, sourceMetadata.name);
|
||||||
|
statement.loc = sourceMetadata.reexportAll.loc;
|
||||||
|
|
||||||
|
// Iterate props creating getter for each prop.
|
||||||
|
statements.push(statement);
|
||||||
|
}
|
||||||
|
return statements;
|
||||||
|
}
|
||||||
|
|
||||||
|
const moduleHeader = template(`
|
||||||
|
Object.defineProperty(EXPORTS, "__esModule", {
|
||||||
|
value: true,
|
||||||
|
})
|
||||||
|
`);
|
||||||
|
|
||||||
|
const moduleHeaderLoose = template(`
|
||||||
|
EXPORTS.__esModule = true;
|
||||||
|
`);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build an "__esModule" header statement setting the property on a given object.
|
||||||
|
*/
|
||||||
|
function buildESModuleHeader(
|
||||||
|
metadata: ModuleMetadata,
|
||||||
|
enumerable: boolean = false,
|
||||||
|
) {
|
||||||
|
if (enumerable) {
|
||||||
|
return moduleHeaderLoose({
|
||||||
|
EXPORTS: t.identifier(metadata.exportName),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return moduleHeader({
|
||||||
|
EXPORTS: t.identifier(metadata.exportName),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const namespaceReexport = template(`
|
||||||
|
Object.keys(NAMESPACE).forEach(function(key) {
|
||||||
|
if (key === "default" || key === "__esModule") return;
|
||||||
|
Object.defineProperty(EXPORTS, key, {
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
|
return NAMESPACE[key];
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a re-export initialization loop for a specific imported namespace.
|
||||||
|
*/
|
||||||
|
function buildNamespaceReexport(metadata, namespace) {
|
||||||
|
// TODO: This should skip exporting a prop that is already exported.
|
||||||
|
return namespaceReexport({
|
||||||
|
NAMESPACE: t.identifier(namespace),
|
||||||
|
EXPORTS: t.identifier(metadata.exportName),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const reexportGetter = template(`
|
||||||
|
Object.defineProperty(EXPORTS, EXPORT_NAME, {
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
|
return NAMESPACE.IMPORT_NAME;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a set of statements that will initialize all of the statically-known
|
||||||
|
* export names with their expected values.
|
||||||
|
*/
|
||||||
|
function buildExportInitializationStatements(
|
||||||
|
programPath: NodePath,
|
||||||
|
metadata: ModuleMetadata,
|
||||||
|
) {
|
||||||
|
const initStatements = [];
|
||||||
|
|
||||||
|
const exportNames = [];
|
||||||
|
for (const [localName, data] of metadata.local) {
|
||||||
|
if (data.kind === "import") {
|
||||||
|
// No-open since these are explicitly set with the "reexports" block.
|
||||||
|
} else if (data.kind === "hoisted") {
|
||||||
|
initStatements.push(
|
||||||
|
buildInitStatement(metadata, data.names, t.identifier(localName)),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
exportNames.push(...data.names);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const [, data] of metadata.source) {
|
||||||
|
for (const [exportName, importName] of data.reexports) {
|
||||||
|
initStatements.push(
|
||||||
|
reexportGetter({
|
||||||
|
EXPORTS: t.identifier(metadata.exportName),
|
||||||
|
EXPORT_NAME: t.stringLiteral(exportName),
|
||||||
|
NAMESPACE: t.identifier(data.name),
|
||||||
|
IMPORT_NAME: t.identifier(importName),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (const exportName of data.reexportNamespace) {
|
||||||
|
exportNames.push(exportName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initStatements.push(
|
||||||
|
...chunk(exportNames, 100).map(members => {
|
||||||
|
return buildInitStatement(
|
||||||
|
metadata,
|
||||||
|
members,
|
||||||
|
programPath.scope.buildUndefinedNode(),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return initStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
const initStatement = template(`
|
||||||
|
EXPORTS.NAME = VALUE;
|
||||||
|
`);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a set of export names, create a set of nested assignments to
|
||||||
|
* initialize them all to a given expression.
|
||||||
|
*/
|
||||||
|
function buildInitStatement(metadata, exportNames, initExpr) {
|
||||||
|
return t.expressionStatement(
|
||||||
|
exportNames.reduce((acc, exportName) => {
|
||||||
|
return initStatement({
|
||||||
|
EXPORTS: t.identifier(metadata.exportName),
|
||||||
|
NAME: t.identifier(exportName),
|
||||||
|
VALUE: acc,
|
||||||
|
}).expression;
|
||||||
|
}, initExpr),
|
||||||
|
);
|
||||||
|
}
|
||||||
413
packages/babel-helper-modules/src/normalize-and-load-metadata.js
Normal file
413
packages/babel-helper-modules/src/normalize-and-load-metadata.js
Normal file
@ -0,0 +1,413 @@
|
|||||||
|
import { basename, extname } from "path";
|
||||||
|
|
||||||
|
import * as t from "babel-types";
|
||||||
|
|
||||||
|
export type ModuleMetadata = {
|
||||||
|
exportName: string,
|
||||||
|
// Lookup from local binding to export information.
|
||||||
|
local: Map<string, LocalExportMetadata>,
|
||||||
|
|
||||||
|
// Lookup of source file to source file metadata.
|
||||||
|
source: Map<string, SourceModuleMetadata>,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type InteropType = "default" | "namespace" | "none";
|
||||||
|
|
||||||
|
export type SourceModuleMetadata = {
|
||||||
|
// A unique variable name to use for this namespace object. Centralized for simplicity.
|
||||||
|
name: string,
|
||||||
|
|
||||||
|
loc: ?BabelNodeSourceLocation,
|
||||||
|
|
||||||
|
interop: InteropType,
|
||||||
|
|
||||||
|
// Local binding to reference from this source namespace. Key: Local name, value: Import name
|
||||||
|
imports: Map<string, string>,
|
||||||
|
|
||||||
|
// Local names that reference namespace object.
|
||||||
|
importsNamespace: Set<string>,
|
||||||
|
|
||||||
|
// Reexports to create for namespace. Key: Export name, value: Import name
|
||||||
|
reexports: Map<string, string>,
|
||||||
|
|
||||||
|
// List of names to re-export namespace as.
|
||||||
|
reexportNamespace: Set<string>,
|
||||||
|
|
||||||
|
// Tracks if the source should be re-exported.
|
||||||
|
reexportAll: null | {
|
||||||
|
loc: ?BabelNodeSourceLocation,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export type LocalExportMetadata = {
|
||||||
|
name: Array<string>, // names of exports
|
||||||
|
kind: "import" | "hoisted" | "block" | "var",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the module has any exports that need handling.
|
||||||
|
*/
|
||||||
|
export function hasExports(metadata: ModuleMetadata) {
|
||||||
|
const { local, source } = metadata;
|
||||||
|
|
||||||
|
return (
|
||||||
|
local.size > 0 ||
|
||||||
|
Array.from(source).some(([, meta]) => {
|
||||||
|
return (
|
||||||
|
meta.reexports.size > 0 ||
|
||||||
|
meta.reexportNamespace.size > 0 ||
|
||||||
|
!!meta.reexportAll
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given source is an anonymous import, e.g. "import 'foo';"
|
||||||
|
*/
|
||||||
|
export function isSideEffectImport(source: SourceModuleMetadata) {
|
||||||
|
return (
|
||||||
|
source.imports.size === 0 &&
|
||||||
|
source.importsNamespace.size === 0 &&
|
||||||
|
source.reexports.size === 0 &&
|
||||||
|
source.reexportNamespace.size === 0 &&
|
||||||
|
!source.reexportAll
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all imports and exports from the file, and return all metadata
|
||||||
|
* needed to reconstruct the module's behavior.
|
||||||
|
*/
|
||||||
|
export default function normalizeModuleAndLoadMetadata(
|
||||||
|
programPath: NodePath,
|
||||||
|
exportName?: string,
|
||||||
|
{ strict = false, noInterop = false } = {},
|
||||||
|
): ModuleMetadata {
|
||||||
|
if (!exportName) {
|
||||||
|
exportName = programPath.scope.generateUidIdentifier("exports").name;
|
||||||
|
}
|
||||||
|
|
||||||
|
nameAnonymousExports(programPath);
|
||||||
|
|
||||||
|
const { local, source } = getModuleMetadata(programPath, strict);
|
||||||
|
|
||||||
|
removeModuleDeclarations(programPath);
|
||||||
|
|
||||||
|
// Reuse the imported namespace name if there is one.
|
||||||
|
for (const [, metadata] of source) {
|
||||||
|
if (metadata.importsNamespace.size > 0) {
|
||||||
|
// This is kind of gross. If we stop using `loose: true` we should
|
||||||
|
// just make this destructuring assignment.
|
||||||
|
metadata.name = metadata.importsNamespace.values().next().value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noInterop) metadata.interop = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
exportName,
|
||||||
|
local,
|
||||||
|
source,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get metadata about the imports and exports present in this module.
|
||||||
|
*/
|
||||||
|
function getModuleMetadata(programPath: NodePath, strict: boolean = false) {
|
||||||
|
const localData = getLocalExportMetadata(programPath);
|
||||||
|
|
||||||
|
const sourceData = new Map();
|
||||||
|
const getData = sourceNode => {
|
||||||
|
const source = sourceNode.value;
|
||||||
|
|
||||||
|
let data = sourceData.get(source);
|
||||||
|
if (!data) {
|
||||||
|
data = {
|
||||||
|
name: programPath.scope.generateUidIdentifier(
|
||||||
|
basename(source, extname(source)),
|
||||||
|
).name,
|
||||||
|
|
||||||
|
interop: "none",
|
||||||
|
|
||||||
|
loc: null,
|
||||||
|
|
||||||
|
// Data about the requested sources and names.
|
||||||
|
imports: new Map(),
|
||||||
|
importsNamespace: new Set(),
|
||||||
|
|
||||||
|
// Metadata about data that is passed directly from source to export.
|
||||||
|
reexports: new Map(),
|
||||||
|
reexportNamespace: new Set(),
|
||||||
|
reexportAll: null,
|
||||||
|
};
|
||||||
|
sourceData.set(source, data);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
programPath.get("body").forEach(child => {
|
||||||
|
if (child.isImportDeclaration()) {
|
||||||
|
const data = getData(child.node.source);
|
||||||
|
if (!data.loc) data.loc = child.node.loc;
|
||||||
|
|
||||||
|
child.get("specifiers").forEach(spec => {
|
||||||
|
if (spec.isImportDefaultSpecifier()) {
|
||||||
|
if (data.interop === "none") data.interop = "default";
|
||||||
|
|
||||||
|
const localName = spec.get("local").node.name;
|
||||||
|
|
||||||
|
data.imports.set(localName, "default");
|
||||||
|
|
||||||
|
const reexport = localData.get(localName);
|
||||||
|
if (reexport) {
|
||||||
|
localData.delete(localName);
|
||||||
|
|
||||||
|
reexport.names.forEach(name => {
|
||||||
|
data.reexports.set(name, "default");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (spec.isImportNamespaceSpecifier()) {
|
||||||
|
const localName = spec.get("local").node.name;
|
||||||
|
|
||||||
|
if (!strict) data.interop = "namespace";
|
||||||
|
|
||||||
|
data.importsNamespace.add(localName);
|
||||||
|
const reexport = localData.get(localName);
|
||||||
|
if (reexport) {
|
||||||
|
localData.delete(localName);
|
||||||
|
|
||||||
|
reexport.names.forEach(name => {
|
||||||
|
data.reexportNamespace.add(name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (spec.isImportSpecifier()) {
|
||||||
|
const importName = spec.get("imported").node.name;
|
||||||
|
const localName = spec.get("local").node.name;
|
||||||
|
|
||||||
|
data.imports.set(localName, importName);
|
||||||
|
|
||||||
|
if (importName === "default" && data.interop === "none") {
|
||||||
|
data.interop = "default";
|
||||||
|
}
|
||||||
|
|
||||||
|
const reexport = localData.get(localName);
|
||||||
|
if (reexport) {
|
||||||
|
localData.delete(localName);
|
||||||
|
|
||||||
|
reexport.names.forEach(name => {
|
||||||
|
data.reexports.set(name, importName);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (child.isExportAllDeclaration()) {
|
||||||
|
const data = getData(child.node.source);
|
||||||
|
if (!data.loc) data.loc = child.node.loc;
|
||||||
|
|
||||||
|
data.reexportAll = {
|
||||||
|
loc: child.node.loc,
|
||||||
|
};
|
||||||
|
} else if (child.isExportNamedDeclaration() && child.node.source) {
|
||||||
|
const data = getData(child.node.source);
|
||||||
|
if (!data.loc) data.loc = child.node.loc;
|
||||||
|
|
||||||
|
child.get("specifiers").forEach(spec => {
|
||||||
|
if (!spec.isExportSpecifier()) {
|
||||||
|
throw spec.buildCodeFrameError("Unexpected export specifier type");
|
||||||
|
}
|
||||||
|
const importName = spec.get("local").node.name;
|
||||||
|
const exportName = spec.get("exported").node.name;
|
||||||
|
|
||||||
|
if (importName === "default" && data.interop === "none") {
|
||||||
|
data.interop = "default";
|
||||||
|
}
|
||||||
|
|
||||||
|
data.reexports.set(exportName, importName);
|
||||||
|
|
||||||
|
if (exportName === "__esModule") {
|
||||||
|
throw exportName.buildCodeFrameError('Illegal export "__esModule".');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
local: localData,
|
||||||
|
source: sourceData,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get metadata about local variables that are exported.
|
||||||
|
*/
|
||||||
|
function getLocalExportMetadata(
|
||||||
|
programPath: NodePath,
|
||||||
|
): Map<string, LocalExportMetadata> {
|
||||||
|
const bindingKindLookup = new Map();
|
||||||
|
|
||||||
|
programPath.get("body").forEach(child => {
|
||||||
|
let kind;
|
||||||
|
if (child.isImportDeclaration()) {
|
||||||
|
kind = "import";
|
||||||
|
} else {
|
||||||
|
if (child.isExportDefaultDeclaration()) child = child.get("declaration");
|
||||||
|
if (child.isExportNamedDeclaration() && child.node.declaration) {
|
||||||
|
child = child.get("declaration");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (child.isFunctionDeclaration()) {
|
||||||
|
kind = "hoisted";
|
||||||
|
} else if (child.isClassDeclaration()) {
|
||||||
|
kind = "block";
|
||||||
|
} else if (child.isVariableDeclaration({ kind: "var" })) {
|
||||||
|
kind = "var";
|
||||||
|
} else if (child.isVariableDeclaration()) {
|
||||||
|
kind = "block";
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(child.getOuterBindingIdentifiers()).forEach(name => {
|
||||||
|
bindingKindLookup.set(name, kind);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const localMetadata = new Map();
|
||||||
|
const getLocalMetadata = idPath => {
|
||||||
|
const localName = idPath.node.name;
|
||||||
|
let metadata = localMetadata.get(localName);
|
||||||
|
if (!metadata) {
|
||||||
|
const kind = bindingKindLookup.get(localName);
|
||||||
|
|
||||||
|
if (kind === undefined) {
|
||||||
|
throw idPath.buildCodeFrameError(
|
||||||
|
`Exporting local "${localName}", which is not declared.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
metadata = {
|
||||||
|
names: [],
|
||||||
|
kind,
|
||||||
|
};
|
||||||
|
localMetadata.set(localName, metadata);
|
||||||
|
}
|
||||||
|
return metadata;
|
||||||
|
};
|
||||||
|
|
||||||
|
programPath.get("body").forEach(child => {
|
||||||
|
if (child.isExportNamedDeclaration() && !child.node.source) {
|
||||||
|
if (child.node.declaration) {
|
||||||
|
const declaration = child.get("declaration");
|
||||||
|
const ids = declaration.getOuterBindingIdentifierPaths();
|
||||||
|
Object.keys(ids).forEach(name => {
|
||||||
|
if (name === "__esModule") {
|
||||||
|
throw declaration.buildCodeFrameError(
|
||||||
|
'Illegal export "__esModule".',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocalMetadata(ids[name]).names.push(name);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
child.get("specifiers").forEach(spec => {
|
||||||
|
const local = spec.get("local");
|
||||||
|
const exported = spec.get("exported");
|
||||||
|
|
||||||
|
if (exported.node.name === "__esModule") {
|
||||||
|
throw exported.buildCodeFrameError('Illegal export "__esModule".');
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocalMetadata(local).names.push(exported.node.name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (child.isExportDefaultDeclaration()) {
|
||||||
|
const declaration = child.get("declaration");
|
||||||
|
if (
|
||||||
|
declaration.isFunctionDeclaration() ||
|
||||||
|
declaration.isClassDeclaration()
|
||||||
|
) {
|
||||||
|
getLocalMetadata(declaration.get("id")).names.push("default");
|
||||||
|
} else {
|
||||||
|
// These should have been removed by the nameAnonymousExports() call.
|
||||||
|
throw declaration.buildCodeFrameError(
|
||||||
|
"Unexpected default expression export.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return localMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that all exported values have local binding names.
|
||||||
|
*/
|
||||||
|
function nameAnonymousExports(programPath: NodePath) {
|
||||||
|
// Name anonymous exported locals.
|
||||||
|
programPath.get("body").forEach(child => {
|
||||||
|
if (!child.isExportDefaultDeclaration()) return;
|
||||||
|
|
||||||
|
// export default foo;
|
||||||
|
const declaration = child.get("declaration");
|
||||||
|
if (declaration.isFunctionDeclaration()) {
|
||||||
|
if (!declaration.node.id) {
|
||||||
|
declaration.node.id = declaration.scope.generateUidIdentifier(
|
||||||
|
"default",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (declaration.isClassDeclaration()) {
|
||||||
|
if (!declaration.node.id) {
|
||||||
|
declaration.node.id = declaration.scope.generateUidIdentifier(
|
||||||
|
"default",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const id = declaration.scope.generateUidIdentifier("default");
|
||||||
|
const namedDecl = t.exportNamedDeclaration(null, [
|
||||||
|
t.exportSpecifier(t.identifier(id.name), t.identifier("default")),
|
||||||
|
]);
|
||||||
|
namedDecl._blockHoist = child.node._blockHoist;
|
||||||
|
|
||||||
|
const varDecl = t.variableDeclaration("var", [
|
||||||
|
t.variableDeclarator(id, declaration.node),
|
||||||
|
]);
|
||||||
|
varDecl._blockHoist = child.node._blockHoist;
|
||||||
|
|
||||||
|
child.replaceWithMultiple([namedDecl, varDecl]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeModuleDeclarations(programPath: NodePath) {
|
||||||
|
programPath.get("body").forEach(child => {
|
||||||
|
if (child.isImportDeclaration()) {
|
||||||
|
child.remove();
|
||||||
|
} else if (child.isExportNamedDeclaration()) {
|
||||||
|
if (child.node.declaration) {
|
||||||
|
child.node.declaration._blockHoist = child.node._blockHoist;
|
||||||
|
child.replaceWith(child.node.declaration);
|
||||||
|
} else {
|
||||||
|
child.remove();
|
||||||
|
}
|
||||||
|
} else if (child.isExportDefaultDeclaration()) {
|
||||||
|
// export default foo;
|
||||||
|
const declaration = child.get("declaration");
|
||||||
|
if (
|
||||||
|
declaration.isFunctionDeclaration() ||
|
||||||
|
declaration.isClassDeclaration()
|
||||||
|
) {
|
||||||
|
declaration._blockHoist = child.node._blockHoist;
|
||||||
|
child.replaceWith(declaration);
|
||||||
|
} else {
|
||||||
|
// These should have been removed by the nameAnonymousExports() call.
|
||||||
|
throw declaration.buildCodeFrameError(
|
||||||
|
"Unexpected default expression export.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (child.isExportAllDeclaration()) {
|
||||||
|
child.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
349
packages/babel-helper-modules/src/rewrite-live-references.js
Normal file
349
packages/babel-helper-modules/src/rewrite-live-references.js
Normal file
@ -0,0 +1,349 @@
|
|||||||
|
import * as t from "babel-types";
|
||||||
|
import template from "babel-template";
|
||||||
|
|
||||||
|
import type { ModuleMetadata } from "./";
|
||||||
|
|
||||||
|
export default function rewriteLiveReferences(
|
||||||
|
programPath: NodePath,
|
||||||
|
metadata: ModuleMetadata,
|
||||||
|
) {
|
||||||
|
const imported = new Map();
|
||||||
|
const exported = new Map();
|
||||||
|
const requeueInParent = path => {
|
||||||
|
// Manualy re-queue `exports.default =` expressions so that the ES3
|
||||||
|
// transform has an opportunity to convert them. Ideally this would
|
||||||
|
// happen automatically from the replaceWith above. See #4140 for
|
||||||
|
// more info.
|
||||||
|
programPath.requeue(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const [source, data] of metadata.source) {
|
||||||
|
for (const [localName, importName] of data.imports) {
|
||||||
|
imported.set(localName, [source, importName, null]);
|
||||||
|
}
|
||||||
|
for (const localName of data.importsNamespace) {
|
||||||
|
imported.set(localName, [null, null, localName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const [local, data] of metadata.local) {
|
||||||
|
let exportMeta = exported.get(local);
|
||||||
|
if (!exportMeta) {
|
||||||
|
exportMeta = [];
|
||||||
|
exported.set(local, exportMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
exportMeta.push(...data.names);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite inititialization of bindings to update exports.
|
||||||
|
programPath.traverse(rewriteBindingInitVisitor, {
|
||||||
|
metadata,
|
||||||
|
requeueInParent,
|
||||||
|
scope: programPath.scope,
|
||||||
|
exported, // local name => exported name list
|
||||||
|
});
|
||||||
|
|
||||||
|
// Rewrite reads/writes from imports and exports to have the correct behavior.
|
||||||
|
programPath.traverse(rewriteReferencesVisitor, {
|
||||||
|
seen: new WeakSet(),
|
||||||
|
metadata,
|
||||||
|
requeueInParent,
|
||||||
|
scope: programPath.scope,
|
||||||
|
imported, // local / import
|
||||||
|
exported, // local name => exported name list
|
||||||
|
buildImportReference: ([source, importName, localName]) => {
|
||||||
|
if (localName) return null;
|
||||||
|
|
||||||
|
const name = metadata.source.get(source).name;
|
||||||
|
|
||||||
|
return t.memberExpression(t.identifier(name), t.identifier(importName));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A visitor to inject export update statements during binding initialization.
|
||||||
|
*/
|
||||||
|
const rewriteBindingInitVisitor = {
|
||||||
|
ClassProperty(path) {
|
||||||
|
path.skip();
|
||||||
|
},
|
||||||
|
Function(path) {
|
||||||
|
path.skip();
|
||||||
|
},
|
||||||
|
ClassDeclaration(path) {
|
||||||
|
const { requeueInParent, exported, metadata } = this;
|
||||||
|
|
||||||
|
const { id } = path.node;
|
||||||
|
if (!id) throw new Error("Expected class to have a name");
|
||||||
|
const localName = id.name;
|
||||||
|
|
||||||
|
const exportNames = exported.get(localName) || [];
|
||||||
|
if (exportNames.length > 0) {
|
||||||
|
const statement = t.expressionStatement(
|
||||||
|
buildBindingExportAssignmentExpression(
|
||||||
|
metadata,
|
||||||
|
exportNames,
|
||||||
|
t.identifier(localName),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
requeueInParent(path.insertAfter(statement)[0]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
VariableDeclaration(path) {
|
||||||
|
const { requeueInParent, exported, metadata } = this;
|
||||||
|
|
||||||
|
Object.keys(path.getOuterBindingIdentifiers()).forEach(localName => {
|
||||||
|
const exportNames = exported.get(localName) || [];
|
||||||
|
if (exportNames.length > 0) {
|
||||||
|
const statement = t.expressionStatement(
|
||||||
|
buildBindingExportAssignmentExpression(
|
||||||
|
metadata,
|
||||||
|
exportNames,
|
||||||
|
t.identifier(localName),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
requeueInParent(path.insertAfter(statement)[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildBindingExportAssignmentExpression = (
|
||||||
|
metadata,
|
||||||
|
exportNames,
|
||||||
|
localExpr,
|
||||||
|
) => {
|
||||||
|
return (exportNames || []).reduce((expr, exportName) => {
|
||||||
|
// class Foo {} export { Foo, Foo as Bar };
|
||||||
|
// as
|
||||||
|
// class Foo {} exports.Foo = exports.Bar = Foo;
|
||||||
|
return t.assignmentExpression(
|
||||||
|
"=",
|
||||||
|
t.memberExpression(
|
||||||
|
t.identifier(metadata.exportName),
|
||||||
|
t.identifier(exportName),
|
||||||
|
),
|
||||||
|
expr,
|
||||||
|
);
|
||||||
|
}, localExpr);
|
||||||
|
};
|
||||||
|
|
||||||
|
const importThrow = template(`
|
||||||
|
(function() {
|
||||||
|
throw new Error('"' + NAME + '" is read-only.');
|
||||||
|
})();
|
||||||
|
`);
|
||||||
|
|
||||||
|
const buildImportThrow = localName => {
|
||||||
|
return importThrow({
|
||||||
|
NAME: t.stringLiteral(localName),
|
||||||
|
}).expression;
|
||||||
|
};
|
||||||
|
|
||||||
|
const rewriteReferencesVisitor = {
|
||||||
|
ReferencedIdentifier(path) {
|
||||||
|
const {
|
||||||
|
seen,
|
||||||
|
buildImportReference,
|
||||||
|
scope,
|
||||||
|
imported,
|
||||||
|
requeueInParent,
|
||||||
|
} = this;
|
||||||
|
if (seen.has(path.node)) return;
|
||||||
|
seen.add(path.node);
|
||||||
|
|
||||||
|
const localName = path.node.name;
|
||||||
|
|
||||||
|
const localBinding = path.scope.getBinding(localName);
|
||||||
|
const rootBinding = scope.getBinding(localName);
|
||||||
|
|
||||||
|
// redeclared in this scope
|
||||||
|
if (rootBinding !== localBinding) return;
|
||||||
|
|
||||||
|
const importData = imported.get(localName);
|
||||||
|
if (importData) {
|
||||||
|
const ref = buildImportReference(importData) || path.node;
|
||||||
|
|
||||||
|
if (path.parentPath.isCallExpression({ callee: path.node })) {
|
||||||
|
path.replaceWith(t.sequenceExpression([t.numericLiteral(0), ref]));
|
||||||
|
} else if (path.isJSXIdentifier() && t.isMemberExpression(ref)) {
|
||||||
|
const { object, property } = ref;
|
||||||
|
path.replaceWith(
|
||||||
|
t.JSXMemberExpression(
|
||||||
|
t.JSXIdentifier(object.name),
|
||||||
|
t.JSXIdentifier(property.name),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
path.replaceWith(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
requeueInParent(path);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
UpdateExpression: {
|
||||||
|
exit(path) {
|
||||||
|
const { scope, imported, exported } = this;
|
||||||
|
|
||||||
|
const arg = path.get("argument");
|
||||||
|
if (!arg.isIdentifier()) return;
|
||||||
|
const localName = arg.node.name;
|
||||||
|
|
||||||
|
if (!imported.has(localName) && !exported.has(localName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// redeclared in this scope
|
||||||
|
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const exportedNames = exported.get(localName) || [];
|
||||||
|
|
||||||
|
if (exportedNames.length > 0 || imported.has(localName)) {
|
||||||
|
if (
|
||||||
|
path.node.prefix ||
|
||||||
|
(path.parentPath.isExpressionStatement() &&
|
||||||
|
!path.isCompletionRecord())
|
||||||
|
) {
|
||||||
|
// ++i => (i += 1);
|
||||||
|
path.replaceWith(
|
||||||
|
t.assignmentExpression("+=", arg.node, t.numericLiteral(1)),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const varName = path.scope.generateDeclaredUidIdentifier("old");
|
||||||
|
|
||||||
|
const assignment = t.binaryExpression(
|
||||||
|
path.node.operator.slice(0, 1),
|
||||||
|
varName,
|
||||||
|
t.numericLiteral(1),
|
||||||
|
);
|
||||||
|
|
||||||
|
// i++ => (_tmp = i, i = _tmp + 1, _tmp)
|
||||||
|
path.replaceWith(
|
||||||
|
t.sequenceExpression([
|
||||||
|
t.assignmentExpression("=", varName, arg.node),
|
||||||
|
t.assignmentExpression("=", arg.node, assignment),
|
||||||
|
varName,
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
AssignmentExpression: {
|
||||||
|
exit(path) {
|
||||||
|
const {
|
||||||
|
scope,
|
||||||
|
seen,
|
||||||
|
imported,
|
||||||
|
exported,
|
||||||
|
requeueInParent,
|
||||||
|
buildImportReference,
|
||||||
|
} = this;
|
||||||
|
|
||||||
|
if (seen.has(path.node)) return;
|
||||||
|
seen.add(path.node);
|
||||||
|
|
||||||
|
const left = path.get("left");
|
||||||
|
if (left.isIdentifier()) {
|
||||||
|
// Simple update-assign foo += 1; export { foo };
|
||||||
|
// => exports.foo = (foo += 1);
|
||||||
|
const localName = left.node.name;
|
||||||
|
|
||||||
|
// redeclared in this scope
|
||||||
|
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const exportedNames = exported.get(localName) || [];
|
||||||
|
const importData = imported.get(localName);
|
||||||
|
if (exportedNames.length > 0 || importData) {
|
||||||
|
const assignment = path.node;
|
||||||
|
|
||||||
|
if (importData) {
|
||||||
|
assignment.left =
|
||||||
|
buildImportReference(importData) || assignment.left;
|
||||||
|
|
||||||
|
if (path.node.operator !== "=") {
|
||||||
|
const op = path.node.operator.slice(0, -1);
|
||||||
|
path.node.operator = "=";
|
||||||
|
|
||||||
|
assignment.right = t.binaryExpression(
|
||||||
|
op,
|
||||||
|
assignment.left,
|
||||||
|
assignment.right,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
assignment.right = t.sequenceExpression([
|
||||||
|
assignment.right,
|
||||||
|
buildImportThrow(localName),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
path.replaceWith(
|
||||||
|
buildBindingExportAssignmentExpression(
|
||||||
|
this.metadata,
|
||||||
|
exportedNames,
|
||||||
|
assignment,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
requeueInParent(path);
|
||||||
|
}
|
||||||
|
} else if (left.isMemberExpression()) {
|
||||||
|
// No change needed
|
||||||
|
} else {
|
||||||
|
const ids = left.getOuterBindingIdentifiers();
|
||||||
|
const id = Object.keys(ids)
|
||||||
|
.filter(localName => imported.has(localName))
|
||||||
|
.pop();
|
||||||
|
if (id) {
|
||||||
|
path.node.right = t.sequenceExpression([
|
||||||
|
path.node.right,
|
||||||
|
buildImportThrow(id),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Complex ({a, b, c} = {}); export { a, c };
|
||||||
|
// => ({a, b, c} = {}), (exports.a = a, exports.c = c);
|
||||||
|
const items = [];
|
||||||
|
Object.keys(ids).forEach(localName => {
|
||||||
|
// redeclared in this scope
|
||||||
|
if (
|
||||||
|
scope.getBinding(localName) !== path.scope.getBinding(localName)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const exportedNames = exported.get(localName) || [];
|
||||||
|
if (exportedNames.length > 0) {
|
||||||
|
items.push(
|
||||||
|
buildBindingExportAssignmentExpression(
|
||||||
|
this.metadata,
|
||||||
|
exportedNames,
|
||||||
|
t.identifier(localName),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (items.length > 0) {
|
||||||
|
let node = t.sequenceExpression(items);
|
||||||
|
if (path.parentPath.isExpressionStatement()) {
|
||||||
|
node = t.expressionStatement(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
const statement = path.insertAfter(node)[0];
|
||||||
|
requeueInParent(statement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
20
packages/babel-helper-modules/src/rewrite-this.js
Normal file
20
packages/babel-helper-modules/src/rewrite-this.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
export default function rewriteThis(programPath: NodePath) {
|
||||||
|
// Rewrite "this" to be "undefined".
|
||||||
|
programPath.traverse(rewriteThisVisitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A visitor to walk the tree, rewriting all `this` references in the top-level scope to be
|
||||||
|
* `undefined`.
|
||||||
|
*/
|
||||||
|
const rewriteThisVisitor = {
|
||||||
|
ThisExpression(path) {
|
||||||
|
path.replaceWith(path.scope.buildUndefinedNode());
|
||||||
|
},
|
||||||
|
Function(path) {
|
||||||
|
if (!path.isArrowFunctionExpression()) path.skip();
|
||||||
|
},
|
||||||
|
ClassProperty(path) {
|
||||||
|
path.skip();
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -18,7 +18,7 @@ export default function({ messages, types: t }) {
|
|||||||
Scope({ scope }) {
|
Scope({ scope }) {
|
||||||
for (const name in scope.bindings) {
|
for (const name in scope.bindings) {
|
||||||
const binding = scope.bindings[name];
|
const binding = scope.bindings[name];
|
||||||
if (binding.kind !== "const" && binding.kind !== "module") continue;
|
if (binding.kind !== "const") continue;
|
||||||
|
|
||||||
for (const violation of (binding.constantViolations: Array)) {
|
for (const violation of (binding.constantViolations: Array)) {
|
||||||
const throwNode = t.throwStatement(
|
const throwNode = t.throwStatement(
|
||||||
|
|||||||
@ -10,18 +10,21 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
|
_exports.default = void 0;
|
||||||
|
|
||||||
exports.default = function (_a) {
|
var _default = function _default(_a) {
|
||||||
return {
|
return {
|
||||||
a: function a() {
|
a: function a() {
|
||||||
return _a;
|
return _a;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -79,6 +79,7 @@ export default function({ types: t }) {
|
|||||||
|
|
||||||
const source = init.node.arguments[0];
|
const source = init.node.arguments[0];
|
||||||
this.sourceNames[source.value] = true;
|
this.sourceNames[source.value] = true;
|
||||||
|
|
||||||
this.sources.push([id.node, source]);
|
this.sources.push([id.node, source]);
|
||||||
|
|
||||||
path.remove();
|
path.remove();
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-plugin-transform-es2015-modules-amd": "7.0.0-beta.0",
|
"babel-helper-modules": "7.0.0-beta.0",
|
||||||
"babel-template": "7.0.0-beta.0"
|
"babel-template": "7.0.0-beta.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@ -1,133 +1,57 @@
|
|||||||
import { basename, extname } from "path";
|
import { basename, extname } from "path";
|
||||||
import template from "babel-template";
|
import template from "babel-template";
|
||||||
import transformAMD from "babel-plugin-transform-es2015-modules-amd";
|
import {
|
||||||
|
rewriteModuleStatementsAndPrepareHeader,
|
||||||
|
hasExports,
|
||||||
|
getSourceMetadataArray,
|
||||||
|
buildNamespaceInitStatements,
|
||||||
|
ensureStatementsHoisted,
|
||||||
|
wrapInterop,
|
||||||
|
} from "babel-helper-modules";
|
||||||
|
|
||||||
const buildPrerequisiteAssignment = template(`
|
const buildPrerequisiteAssignment = template(`
|
||||||
GLOBAL_REFERENCE = GLOBAL_REFERENCE || {}
|
GLOBAL_REFERENCE = GLOBAL_REFERENCE || {}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
const buildGlobalExport = template(`
|
|
||||||
var mod = { exports: {} };
|
|
||||||
factory(BROWSER_ARGUMENTS);
|
|
||||||
PREREQUISITE_ASSIGNMENTS
|
|
||||||
GLOBAL_TO_ASSIGN = mod.exports;
|
|
||||||
`);
|
|
||||||
|
|
||||||
const buildWrapper = template(`
|
const buildWrapper = template(`
|
||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
if (typeof define === "function" && define.amd) {
|
if (typeof define === "function" && define.amd) {
|
||||||
define(MODULE_NAME, AMD_ARGUMENTS, factory);
|
define(MODULE_NAME, AMD_ARGUMENTS, factory);
|
||||||
} else if (typeof exports !== "undefined") {
|
} else if (typeof exports !== "undefined") {
|
||||||
factory(COMMON_ARGUMENTS);
|
factory(COMMONJS_ARGUMENTS);
|
||||||
} else {
|
} else {
|
||||||
GLOBAL_EXPORT
|
var mod = { exports: {} };
|
||||||
|
factory(BROWSER_ARGUMENTS);
|
||||||
|
|
||||||
|
GLOBAL_TO_ASSIGN;
|
||||||
}
|
}
|
||||||
})(this, FUNC);
|
})(this, function(IMPORT_NAMES) {
|
||||||
|
})
|
||||||
`);
|
`);
|
||||||
|
|
||||||
export default function({ types: t }) {
|
export default function({ types: t }) {
|
||||||
function isValidDefine(path) {
|
/**
|
||||||
if (!path.isExpressionStatement()) return;
|
* Build the assignment statements that initialize the UMD global.
|
||||||
|
*/
|
||||||
const expr = path.get("expression");
|
function buildBrowserInit(browserGlobals, exactGlobals, file, moduleName) {
|
||||||
if (!expr.isCallExpression()) return false;
|
|
||||||
if (!expr.get("callee").isIdentifier({ name: "define" })) return false;
|
|
||||||
|
|
||||||
const args = expr.get("arguments");
|
|
||||||
if (args.length === 3 && !args.shift().isStringLiteral()) return false;
|
|
||||||
if (args.length !== 2) return false;
|
|
||||||
if (!args.shift().isArrayExpression()) return false;
|
|
||||||
if (!args.shift().isFunctionExpression()) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
inherits: transformAMD,
|
|
||||||
|
|
||||||
visitor: {
|
|
||||||
Program: {
|
|
||||||
exit(path, state) {
|
|
||||||
const last = path.get("body").pop();
|
|
||||||
if (!isValidDefine(last)) return;
|
|
||||||
|
|
||||||
const call = last.node.expression;
|
|
||||||
const args = call.arguments;
|
|
||||||
|
|
||||||
const moduleName = args.length === 3 ? args.shift() : null;
|
|
||||||
const amdArgs = call.arguments[0];
|
|
||||||
const func = call.arguments[1];
|
|
||||||
const browserGlobals = state.opts.globals || {};
|
|
||||||
|
|
||||||
const commonArgs = amdArgs.elements.map(arg => {
|
|
||||||
if (arg.value === "module" || arg.value === "exports") {
|
|
||||||
return t.identifier(arg.value);
|
|
||||||
} else {
|
|
||||||
return t.callExpression(t.identifier("require"), [arg]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const browserArgs = amdArgs.elements.map(arg => {
|
|
||||||
if (arg.value === "module") {
|
|
||||||
return t.identifier("mod");
|
|
||||||
} else if (arg.value === "exports") {
|
|
||||||
return t.memberExpression(
|
|
||||||
t.identifier("mod"),
|
|
||||||
t.identifier("exports"),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
let memberExpression;
|
|
||||||
|
|
||||||
if (state.opts.exactGlobals) {
|
|
||||||
const globalRef = browserGlobals[arg.value];
|
|
||||||
if (globalRef) {
|
|
||||||
memberExpression = globalRef
|
|
||||||
.split(".")
|
|
||||||
.reduce(
|
|
||||||
(accum, curr) =>
|
|
||||||
t.memberExpression(accum, t.identifier(curr)),
|
|
||||||
t.identifier("global"),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
memberExpression = t.memberExpression(
|
|
||||||
t.identifier("global"),
|
|
||||||
t.identifier(t.toIdentifier(arg.value)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const requireName = basename(arg.value, extname(arg.value));
|
|
||||||
const globalName = browserGlobals[requireName] || requireName;
|
|
||||||
memberExpression = t.memberExpression(
|
|
||||||
t.identifier("global"),
|
|
||||||
t.identifier(t.toIdentifier(globalName)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return memberExpression;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const moduleNameOrBasename = moduleName
|
const moduleNameOrBasename = moduleName
|
||||||
? moduleName.value
|
? moduleName.value
|
||||||
: basename(
|
: basename(file.opts.filename, extname(file.opts.filename));
|
||||||
this.file.opts.filename,
|
|
||||||
extname(this.file.opts.filename),
|
|
||||||
);
|
|
||||||
let globalToAssign = t.memberExpression(
|
let globalToAssign = t.memberExpression(
|
||||||
t.identifier("global"),
|
t.identifier("global"),
|
||||||
t.identifier(t.toIdentifier(moduleNameOrBasename)),
|
t.identifier(t.toIdentifier(moduleNameOrBasename)),
|
||||||
);
|
);
|
||||||
let prerequisiteAssignments = null;
|
let initAssignments = [];
|
||||||
|
|
||||||
if (state.opts.exactGlobals) {
|
if (exactGlobals) {
|
||||||
const globalName = browserGlobals[moduleNameOrBasename];
|
const globalName = browserGlobals[moduleNameOrBasename];
|
||||||
|
|
||||||
if (globalName) {
|
if (globalName) {
|
||||||
prerequisiteAssignments = [];
|
initAssignments = [];
|
||||||
|
|
||||||
const members = globalName.split(".");
|
const members = globalName.split(".");
|
||||||
globalToAssign = members.slice(1).reduce((accum, curr) => {
|
globalToAssign = members.slice(1).reduce((accum, curr) => {
|
||||||
prerequisiteAssignments.push(
|
initAssignments.push(
|
||||||
buildPrerequisiteAssignment({ GLOBAL_REFERENCE: accum }),
|
buildPrerequisiteAssignment({ GLOBAL_REFERENCE: accum }),
|
||||||
);
|
);
|
||||||
return t.memberExpression(accum, t.identifier(curr));
|
return t.memberExpression(accum, t.identifier(curr));
|
||||||
@ -135,21 +59,158 @@ export default function({ types: t }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const globalExport = buildGlobalExport({
|
initAssignments.push(
|
||||||
BROWSER_ARGUMENTS: browserArgs,
|
t.expressionStatement(
|
||||||
PREREQUISITE_ASSIGNMENTS: prerequisiteAssignments,
|
t.assignmentExpression(
|
||||||
GLOBAL_TO_ASSIGN: globalToAssign,
|
"=",
|
||||||
|
globalToAssign,
|
||||||
|
t.memberExpression(t.identifier("mod"), t.identifier("exports")),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return initAssignments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the member expression that reads from a global for a given source.
|
||||||
|
*/
|
||||||
|
function buildBrowserArg(browserGlobals, exactGlobals, source) {
|
||||||
|
let memberExpression;
|
||||||
|
if (exactGlobals) {
|
||||||
|
const globalRef = browserGlobals[source];
|
||||||
|
if (globalRef) {
|
||||||
|
memberExpression = globalRef
|
||||||
|
.split(".")
|
||||||
|
.reduce(
|
||||||
|
(accum, curr) => t.memberExpression(accum, t.identifier(curr)),
|
||||||
|
t.identifier("global"),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
memberExpression = t.memberExpression(
|
||||||
|
t.identifier("global"),
|
||||||
|
t.identifier(t.toIdentifier(source)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const requireName = basename(source, extname(source));
|
||||||
|
const globalName = browserGlobals[requireName] || requireName;
|
||||||
|
memberExpression = t.memberExpression(
|
||||||
|
t.identifier("global"),
|
||||||
|
t.identifier(t.toIdentifier(globalName)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return memberExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
visitor: {
|
||||||
|
Program: {
|
||||||
|
exit(path, state) {
|
||||||
|
const {
|
||||||
|
globals,
|
||||||
|
exactGlobals,
|
||||||
|
loose,
|
||||||
|
allowTopLevelThis,
|
||||||
|
strict,
|
||||||
|
strictMode,
|
||||||
|
noInterop,
|
||||||
|
} = state.opts;
|
||||||
|
const browserGlobals = globals || {};
|
||||||
|
|
||||||
|
let moduleName = this.getModuleName();
|
||||||
|
if (moduleName) moduleName = t.stringLiteral(moduleName);
|
||||||
|
|
||||||
|
const {
|
||||||
|
meta,
|
||||||
|
headers,
|
||||||
|
} = rewriteModuleStatementsAndPrepareHeader(path, {
|
||||||
|
loose,
|
||||||
|
strict,
|
||||||
|
strictMode,
|
||||||
|
allowTopLevelThis,
|
||||||
|
noInterop,
|
||||||
});
|
});
|
||||||
|
|
||||||
last.replaceWith(
|
const amdArgs = [];
|
||||||
|
const commonjsArgs = [];
|
||||||
|
const browserArgs = [];
|
||||||
|
const importNames = [];
|
||||||
|
|
||||||
|
if (hasExports(meta)) {
|
||||||
|
amdArgs.push(t.stringLiteral("exports"));
|
||||||
|
commonjsArgs.push(t.identifier("exports"));
|
||||||
|
browserArgs.push(
|
||||||
|
t.memberExpression(t.identifier("mod"), t.identifier("exports")),
|
||||||
|
);
|
||||||
|
importNames.push(t.identifier(meta.exportName));
|
||||||
|
}
|
||||||
|
|
||||||
|
getSourceMetadataArray(
|
||||||
|
meta,
|
||||||
|
).forEach(([source, metadata, , inSideEffectBlock]) => {
|
||||||
|
amdArgs.push(t.stringLiteral(source));
|
||||||
|
commonjsArgs.push(
|
||||||
|
t.callExpression(t.identifier("require"), [
|
||||||
|
t.stringLiteral(source),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
browserArgs.push(
|
||||||
|
buildBrowserArg(browserGlobals, exactGlobals, source),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!inSideEffectBlock) {
|
||||||
|
importNames.push(t.identifier(metadata.name));
|
||||||
|
|
||||||
|
const interop = wrapInterop(
|
||||||
|
path,
|
||||||
|
t.identifier(metadata.name),
|
||||||
|
metadata.interop,
|
||||||
|
);
|
||||||
|
if (interop) {
|
||||||
|
const header = t.expressionStatement(
|
||||||
|
t.assignmentExpression(
|
||||||
|
"=",
|
||||||
|
t.identifier(metadata.name),
|
||||||
|
interop,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
header.loc = meta.loc;
|
||||||
|
headers.push(header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
headers.push(...buildNamespaceInitStatements(meta, metadata));
|
||||||
|
});
|
||||||
|
|
||||||
|
ensureStatementsHoisted(headers);
|
||||||
|
path.unshiftContainer("body", headers);
|
||||||
|
|
||||||
|
const { body, directives } = path.node;
|
||||||
|
path.node.directives = [];
|
||||||
|
path.node.body = [];
|
||||||
|
const umdWrapper = path.pushContainer("body", [
|
||||||
buildWrapper({
|
buildWrapper({
|
||||||
MODULE_NAME: moduleName,
|
MODULE_NAME: moduleName,
|
||||||
AMD_ARGUMENTS: amdArgs,
|
|
||||||
COMMON_ARGUMENTS: commonArgs,
|
AMD_ARGUMENTS: t.arrayExpression(amdArgs),
|
||||||
GLOBAL_EXPORT: globalExport,
|
COMMONJS_ARGUMENTS: commonjsArgs,
|
||||||
FUNC: func,
|
BROWSER_ARGUMENTS: browserArgs,
|
||||||
|
IMPORT_NAMES: importNames,
|
||||||
|
|
||||||
|
GLOBAL_TO_ASSIGN: buildBrowserInit(
|
||||||
|
browserGlobals,
|
||||||
|
exactGlobals,
|
||||||
|
this.file,
|
||||||
|
moduleName,
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
);
|
])[0];
|
||||||
|
const umdFactory = umdWrapper
|
||||||
|
.get("expression.arguments")[1]
|
||||||
|
.get("body");
|
||||||
|
umdFactory.pushContainer("directives", directives);
|
||||||
|
umdFactory.pushContainer("body", body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -10,12 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
|
_exports["default"] = _default;
|
||||||
|
|
||||||
exports["default"] = function () {};
|
function _default() {}
|
||||||
});
|
});
|
||||||
@ -10,14 +10,17 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
|
_exports.default = void 0;
|
||||||
|
|
||||||
exports.default = function () {
|
var _default = function () {
|
||||||
return "foo";
|
return "foo";
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,14 +10,18 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.Cachier = Cachier;
|
_exports.Cachier = Cachier;
|
||||||
exports.default = new Cachier();
|
_exports.default = void 0;
|
||||||
|
|
||||||
|
var _default = new Cachier();
|
||||||
|
|
||||||
|
_exports.default = _default;
|
||||||
|
|
||||||
function Cachier(databaseName) {}
|
function Cachier(databaseName) {}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = {};
|
_exports.default = void 0;
|
||||||
|
var _default = {};
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = [];
|
_exports.default = void 0;
|
||||||
|
var _default = [];
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = foo;
|
_exports.default = void 0;
|
||||||
|
var _default = foo;
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,12 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
|
_exports.default = _default;
|
||||||
|
|
||||||
exports.default = function () {};
|
function _default() {}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,11 +10,15 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = class {};
|
_exports.default = void 0;
|
||||||
|
|
||||||
|
class _default {}
|
||||||
|
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = foo;
|
_exports.default = foo;
|
||||||
|
|
||||||
function foo() {}
|
function foo() {}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,14 +10,15 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
|
_exports.default = void 0;
|
||||||
|
|
||||||
class Foo {}
|
class Foo {}
|
||||||
|
|
||||||
exports.default = Foo;
|
_exports.default = Foo;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,2 +1,3 @@
|
|||||||
|
var foo;
|
||||||
export { foo as default };
|
export { foo as default };
|
||||||
|
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = foo;
|
_exports.default = void 0;
|
||||||
|
var foo;
|
||||||
|
_exports.default = foo;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = 42;
|
_exports.default = void 0;
|
||||||
|
var _default = 42;
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
factory(mod.exports, global.foo);
|
factory(mod.exports, global.foo);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports, _foo) {
|
})(this, function (_exports, _foo) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
Object.defineProperty(exports, "default", {
|
Object.defineProperty(_exports, "default", {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
return _foo.foo;
|
return _foo.foo;
|
||||||
|
|||||||
@ -10,19 +10,19 @@
|
|||||||
factory(mod.exports, global.foo);
|
factory(mod.exports, global.foo);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports, _foo) {
|
})(this, function (_exports, _foo) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
Object.defineProperty(exports, "default", {
|
Object.defineProperty(_exports, "default", {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
return _foo.foo;
|
return _foo.foo;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Object.defineProperty(exports, "bar", {
|
Object.defineProperty(_exports, "bar", {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
return _foo.bar;
|
return _foo.bar;
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
factory(mod.exports, global.foo);
|
factory(mod.exports, global.foo);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports, _foo) {
|
})(this, function (_exports, _foo) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
Object.defineProperty(exports, "bar", {
|
Object.defineProperty(_exports, "bar", {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
return _foo.foo;
|
return _foo.foo;
|
||||||
|
|||||||
@ -10,19 +10,19 @@
|
|||||||
factory(mod.exports, global.foo);
|
factory(mod.exports, global.foo);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports, _foo) {
|
})(this, function (_exports, _foo) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
Object.defineProperty(exports, "foo", {
|
Object.defineProperty(_exports, "foo", {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
return _foo.foo;
|
return _foo.foo;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Object.defineProperty(exports, "bar", {
|
Object.defineProperty(_exports, "bar", {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
return _foo.bar;
|
return _foo.bar;
|
||||||
|
|||||||
@ -10,15 +10,15 @@
|
|||||||
factory(mod.exports, global.foo);
|
factory(mod.exports, global.foo);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports, _foo) {
|
})(this, function (_exports, _foo) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
Object.keys(_foo).forEach(function (key) {
|
Object.keys(_foo).forEach(function (key) {
|
||||||
if (key === "default" || key === "__esModule") return;
|
if (key === "default" || key === "__esModule") return;
|
||||||
Object.defineProperty(exports, key, {
|
Object.defineProperty(_exports, key, {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
return _foo[key];
|
return _foo[key];
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
factory(mod.exports, global.foo);
|
factory(mod.exports, global.foo);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports, _foo) {
|
})(this, function (_exports, _foo) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
Object.defineProperty(exports, "foo", {
|
Object.defineProperty(_exports, "foo", {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
return _foo.foo;
|
return _foo.foo;
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
|
var foo;
|
||||||
export {foo as default};
|
export {foo as default};
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = foo;
|
_exports.default = void 0;
|
||||||
|
var foo;
|
||||||
|
_exports.default = foo;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
|
var foo, bar;
|
||||||
export {foo as default, bar};
|
export {foo as default, bar};
|
||||||
|
|||||||
@ -10,12 +10,14 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = foo;
|
_exports.bar = _exports.default = void 0;
|
||||||
exports.bar = bar;
|
var foo, bar;
|
||||||
|
_exports.bar = bar;
|
||||||
|
_exports.default = foo;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
|
var foo;
|
||||||
export {foo as bar};
|
export {foo as bar};
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.bar = foo;
|
_exports.bar = void 0;
|
||||||
|
var foo;
|
||||||
|
_exports.bar = foo;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
|
var foo, bar;
|
||||||
export {foo, bar};
|
export {foo, bar};
|
||||||
|
|||||||
@ -10,12 +10,14 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.foo = foo;
|
_exports.bar = _exports.foo = void 0;
|
||||||
exports.bar = bar;
|
var foo, bar;
|
||||||
|
_exports.bar = bar;
|
||||||
|
_exports.foo = foo;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
|
var foo;
|
||||||
export {foo};
|
export {foo};
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.foo = foo;
|
_exports.foo = void 0;
|
||||||
|
var foo;
|
||||||
|
_exports.foo = foo;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,27 +10,36 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.foo8 = foo8;
|
_exports.foo8 = foo8;
|
||||||
var foo = exports.foo = 1;
|
_exports.foo9 = _exports.foo7 = _exports.foo6 = _exports.foo5 = _exports.foo4 = _exports.foo3 = _exports.bar = _exports.foo2 = _exports.foo = void 0;
|
||||||
var foo2 = exports.foo2 = 1,
|
var foo = 1;
|
||||||
bar = exports.bar = 2;
|
_exports.foo = foo;
|
||||||
|
var foo2 = 1,
|
||||||
|
bar = 2;
|
||||||
|
_exports.bar = bar;
|
||||||
|
_exports.foo2 = foo2;
|
||||||
|
|
||||||
var foo3 = exports.foo3 = function () {};
|
var foo3 = function () {};
|
||||||
|
|
||||||
var foo4 = exports.foo4 = void 0;
|
_exports.foo3 = foo3;
|
||||||
let foo5 = exports.foo5 = 2;
|
var foo4;
|
||||||
let foo6 = exports.foo6 = void 0;
|
_exports.foo4 = foo4;
|
||||||
const foo7 = exports.foo7 = 3;
|
let foo5 = 2;
|
||||||
|
_exports.foo5 = foo5;
|
||||||
|
let foo6;
|
||||||
|
_exports.foo6 = foo6;
|
||||||
|
const foo7 = 3;
|
||||||
|
_exports.foo7 = foo7;
|
||||||
|
|
||||||
function foo8() {}
|
function foo8() {}
|
||||||
|
|
||||||
class foo9 {}
|
class foo9 {}
|
||||||
|
|
||||||
exports.foo9 = foo9;
|
_exports.foo9 = foo9;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,22 +10,24 @@
|
|||||||
factory(mod.exports, global.evens);
|
factory(mod.exports, global.evens);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports, _evens) {
|
})(this, function (_exports, _evens) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.isOdd = void 0;
|
_exports.nextOdd = nextOdd;
|
||||||
exports.nextOdd = nextOdd;
|
_exports.isOdd = void 0;
|
||||||
|
|
||||||
function nextOdd(n) {
|
function nextOdd(n) {
|
||||||
return (0, _evens.isEven)(n) ? n + 1 : n + 2;
|
return (0, _evens.isEven)(n) ? n + 1 : n + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isOdd = exports.isOdd = function (isEven) {
|
var isOdd = function (isEven) {
|
||||||
return function (n) {
|
return function (n) {
|
||||||
return !isEven(n);
|
return !isEven(n);
|
||||||
};
|
};
|
||||||
}(_evens.isEven);
|
}(_evens.isEven);
|
||||||
|
|
||||||
|
_exports.isOdd = isOdd;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,8 +13,7 @@
|
|||||||
})(this, function (_foo) {
|
})(this, function (_foo) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _foo2 = babelHelpers.interopRequireDefault(_foo);
|
_foo = babelHelpers.interopRequireDefault(_foo);
|
||||||
|
_foo.default;
|
||||||
_foo2.default;
|
_foo.default;
|
||||||
_foo2.default;
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,12 +10,10 @@
|
|||||||
factory(global.fooBAR, global.fooBAR, global.fizzBuzz);
|
factory(global.fooBAR, global.fooBAR, global.fizzBuzz);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (_fooBar, _fooBar3, _fizzbuzz) {
|
})(this, function (_fooBar, _fooBar2, _fizzbuzz) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _fooBar2 = babelHelpers.interopRequireDefault(_fooBar);
|
_fooBar = babelHelpers.interopRequireDefault(_fooBar);
|
||||||
|
_fooBar2 = babelHelpers.interopRequireDefault(_fooBar2);
|
||||||
var _fooBar4 = babelHelpers.interopRequireDefault(_fooBar3);
|
_fizzbuzz = babelHelpers.interopRequireDefault(_fizzbuzz);
|
||||||
|
|
||||||
var _fizzbuzz2 = babelHelpers.interopRequireDefault(_fizzbuzz);
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,12 +10,10 @@
|
|||||||
factory(global.fooBar, global.fooBar, global.fizzbuzz);
|
factory(global.fooBar, global.fooBar, global.fizzbuzz);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (_fooBar, _fooBar3, _fizzbuzz) {
|
})(this, function (_fooBar, _fooBar2, _fizzbuzz) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _fooBar2 = babelHelpers.interopRequireDefault(_fooBar);
|
_fooBar = babelHelpers.interopRequireDefault(_fooBar);
|
||||||
|
_fooBar2 = babelHelpers.interopRequireDefault(_fooBar2);
|
||||||
var _fooBar4 = babelHelpers.interopRequireDefault(_fooBar3);
|
_fizzbuzz = babelHelpers.interopRequireDefault(_fizzbuzz);
|
||||||
|
|
||||||
var _fizzbuzz2 = babelHelpers.interopRequireDefault(_fizzbuzz);
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,12 +10,10 @@
|
|||||||
factory(global.fooBAR, global.mylib.fooBar, global.fizz.buzz);
|
factory(global.fooBAR, global.mylib.fooBar, global.fizz.buzz);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (_fooBar, _fooBar3, _fizzbuzz) {
|
})(this, function (_fooBar, _fooBar2, _fizzbuzz) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _fooBar2 = babelHelpers.interopRequireDefault(_fooBar);
|
_fooBar = babelHelpers.interopRequireDefault(_fooBar);
|
||||||
|
_fooBar2 = babelHelpers.interopRequireDefault(_fooBar2);
|
||||||
var _fooBar4 = babelHelpers.interopRequireDefault(_fooBar3);
|
_fizzbuzz = babelHelpers.interopRequireDefault(_fizzbuzz);
|
||||||
|
|
||||||
var _fizzbuzz2 = babelHelpers.interopRequireDefault(_fizzbuzz);
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,12 +10,10 @@
|
|||||||
factory(global.fooBar, global.mylibFooBar, global.fizzbuzz);
|
factory(global.fooBar, global.mylibFooBar, global.fizzbuzz);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (_fooBar, _fooBar3, _fizzbuzz) {
|
})(this, function (_fooBar, _fooBar2, _fizzbuzz) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _fooBar2 = babelHelpers.interopRequireDefault(_fooBar);
|
_fooBar = babelHelpers.interopRequireDefault(_fooBar);
|
||||||
|
_fooBar2 = babelHelpers.interopRequireDefault(_fooBar2);
|
||||||
var _fooBar4 = babelHelpers.interopRequireDefault(_fooBar3);
|
_fizzbuzz = babelHelpers.interopRequireDefault(_fizzbuzz);
|
||||||
|
|
||||||
var _fizzbuzz2 = babelHelpers.interopRequireDefault(_fizzbuzz);
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,9 +10,9 @@
|
|||||||
factory(global.foo);
|
factory(global.foo);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (_foo) {
|
})(this, function (foo) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var foo = babelHelpers.interopRequireWildcard(_foo);
|
foo = babelHelpers.interopRequireWildcard(foo);
|
||||||
foo;
|
foo;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
})(this, function (_foo) {
|
})(this, function (_foo) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _foo2 = babelHelpers.interopRequireDefault(_foo);
|
_foo = babelHelpers.interopRequireDefault(_foo);
|
||||||
|
|
||||||
_foo.baz;
|
_foo.baz;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,11 +11,13 @@
|
|||||||
global.foo = global.foo || {};
|
global.foo = global.foo || {};
|
||||||
global.foo.bar = mod.exports;
|
global.foo.bar = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = 42;
|
_exports.default = void 0;
|
||||||
|
var _default = 42;
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,11 +13,13 @@
|
|||||||
global.foo.bar.baz = global.foo.bar.baz || {};
|
global.foo.bar.baz = global.foo.bar.baz || {};
|
||||||
global.foo.bar.baz.qux = mod.exports;
|
global.foo.bar.baz.qux = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = 42;
|
_exports.default = void 0;
|
||||||
|
var _default = 42;
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.baz = mod.exports;
|
global.baz = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = 42;
|
_exports.default = void 0;
|
||||||
|
var _default = 42;
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.baz = mod.exports;
|
global.baz = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = 42;
|
_exports.default = void 0;
|
||||||
|
var _default = 42;
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.baz = mod.exports;
|
global.baz = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = 42;
|
_exports.default = void 0;
|
||||||
|
var _default = 42;
|
||||||
|
_exports.default = _default;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import * as foo2 from "foo";
|
|||||||
import {bar} from "foo";
|
import {bar} from "foo";
|
||||||
import {foo as bar2} from "foo";
|
import {foo as bar2} from "foo";
|
||||||
|
|
||||||
|
var test;
|
||||||
export {test};
|
export {test};
|
||||||
export var test2 = 5;
|
export var test2 = 5;
|
||||||
|
|
||||||
|
|||||||
@ -10,17 +10,20 @@
|
|||||||
factory(mod.exports, global.foo, global.fooBar, global.fooBar);
|
factory(mod.exports, global.foo, global.fooBar, global.fooBar);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports, _foo) {
|
})(this, function (_exports, foo2) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.test2 = exports.test = void 0;
|
_exports.default = _exports.test2 = _exports.test = void 0;
|
||||||
var foo2 = babelHelpers.interopRequireWildcard(_foo);
|
foo2 = babelHelpers.interopRequireWildcard(foo2);
|
||||||
exports.test = test;
|
var test;
|
||||||
var test2 = exports.test2 = 5;
|
_exports.test = test;
|
||||||
exports.default = test;
|
var test2 = 5;
|
||||||
_foo.bar;
|
_exports.test2 = test2;
|
||||||
_foo.foo;
|
var _default = test;
|
||||||
|
_exports.default = _default;
|
||||||
|
foo2.bar;
|
||||||
|
foo2.foo;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,15 +10,17 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
var test = exports.test = 2;
|
_exports.f = _exports.e = _exports.c = _exports.a = _exports.test = void 0;
|
||||||
exports.test = test = 5;
|
var test = 2;
|
||||||
exports.test = test += 1;
|
_exports.test = test;
|
||||||
|
_exports.test = test = 5;
|
||||||
|
_exports.test = test += 1;
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var test = 2;
|
var test = 2;
|
||||||
@ -27,13 +29,12 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
var a = 2;
|
var a = 2;
|
||||||
exports.a = a;
|
_exports.a = a;
|
||||||
exports.a = a = 3;
|
_exports.a = a = 3;
|
||||||
var b = 2;
|
var b = 2;
|
||||||
exports.c = b;
|
_exports.c = b;
|
||||||
exports.c = b = 3;
|
_exports.c = b = 3;
|
||||||
var d = 3;
|
var d = 3;
|
||||||
exports.e = d;
|
_exports.f = _exports.e = d;
|
||||||
exports.f = d;
|
_exports.f = _exports.e = d = 4;
|
||||||
exports.f = exports.e = d = 4;
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
factory(mod.exports);
|
factory(mod.exports);
|
||||||
global.actual = mod.exports;
|
global.actual = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (exports) {
|
})(this, function (_exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(_exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.a = a;
|
_exports.a = a;
|
||||||
|
|
||||||
function a() {}
|
function a() {}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user