From 1938f490b3509532f0e2c84b7a8b6f3cd1466000 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 29 Sep 2017 11:02:23 -0700 Subject: [PATCH 1/8] Move pipeline file to index. --- packages/babel-core/src/index.js | 2 +- .../babel-core/src/transformation/{pipeline.js => index.js} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/babel-core/src/transformation/{pipeline.js => index.js} (100%) diff --git a/packages/babel-core/src/index.js b/packages/babel-core/src/index.js index 35e8e5c77f..7df67c775b 100644 --- a/packages/babel-core/src/index.js +++ b/packages/babel-core/src/index.js @@ -35,7 +35,7 @@ export { transformFromAst, transformFile, transformFileSync, -} from "./transformation/pipeline"; +} from "./transformation"; /** * Recommended set of compilable extensions. Not used in babel-core directly, but meant as diff --git a/packages/babel-core/src/transformation/pipeline.js b/packages/babel-core/src/transformation/index.js similarity index 100% rename from packages/babel-core/src/transformation/pipeline.js rename to packages/babel-core/src/transformation/index.js From c8835cbbee114e83f0ff98dd5816695cd4d08829 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 29 Sep 2017 11:05:57 -0700 Subject: [PATCH 2/8] Remove unnecessary Store subclass. --- .../babel-core/src/transformation/file/index.js | 14 ++++++++++---- .../babel-core/src/transformation/plugin-pass.js | 13 ++++++++++--- packages/babel-core/src/transformation/store.js | 15 --------------- 3 files changed, 20 insertions(+), 22 deletions(-) delete mode 100644 packages/babel-core/src/transformation/store.js diff --git a/packages/babel-core/src/transformation/file/index.js b/packages/babel-core/src/transformation/file/index.js index 38947d5397..b48c1581bc 100644 --- a/packages/babel-core/src/transformation/file/index.js +++ b/packages/babel-core/src/transformation/file/index.js @@ -9,7 +9,6 @@ import sourceMap from "source-map"; import generate from "babel-generator"; import { codeFrameColumns } from "babel-code-frame"; import traverse from "babel-traverse"; -import Store from "../store"; import { parse } from "babylon"; import * as t from "babel-types"; import buildDebug from "debug"; @@ -38,7 +37,7 @@ const errorVisitor = { }, }; -export default class File extends Store { +export default class File { constructor({ options, passes }: ResolvedConfig) { if (!INTERNAL_PLUGINS) { // Lazy-init the internal plugin to remove the init-time circular dependency between plugins being @@ -49,8 +48,7 @@ export default class File extends Store { }).passes[0]; } - super(); - + this._map = new Map(); this.pluginPasses = passes; this.opts = options; @@ -113,6 +111,14 @@ export default class File extends Store { code: string; shebang: string; + set(key: string, val) { + this._map.set(key, val); + } + + get(key: string): any { + return this._map.get(key); + } + getMetadata() { let has = false; for (const node of (this.ast.program.body: Array)) { diff --git a/packages/babel-core/src/transformation/plugin-pass.js b/packages/babel-core/src/transformation/plugin-pass.js index c0a6626cf5..edde9acd07 100644 --- a/packages/babel-core/src/transformation/plugin-pass.js +++ b/packages/babel-core/src/transformation/plugin-pass.js @@ -1,9 +1,8 @@ -import Store from "./store"; import File from "./file"; -export default class PluginPass extends Store { +export default class PluginPass { constructor(file: File, key: string, options: Object = {}) { - super(); + this._map = new Map(); this.key = key; this.file = file; @@ -14,6 +13,14 @@ export default class PluginPass extends Store { file: File; opts: Object; + set(key: string, val) { + this._map.set(key, val); + } + + get(key: string): any { + return this._map.get(key); + } + addHelper(...args) { return this.file.addHelper(...args); } diff --git a/packages/babel-core/src/transformation/store.js b/packages/babel-core/src/transformation/store.js deleted file mode 100644 index bcf5bc7e4b..0000000000 --- a/packages/babel-core/src/transformation/store.js +++ /dev/null @@ -1,15 +0,0 @@ -export default class Store { - constructor() { - this._map = new Map(); - } - - set(key: string, val) { - this._map.set(key, val); - } - - get(key: string): any { - if (this._map.has(key)) { - return this._map.get(key); - } - } -} From 455cb5b8d8e6fe4dc9cb8763ae198ab6d1f1137d Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 29 Sep 2017 11:43:23 -0700 Subject: [PATCH 3/8] Remove unused file properties. --- packages/babel-core/src/transformation/file/index.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/babel-core/src/transformation/file/index.js b/packages/babel-core/src/transformation/file/index.js index b48c1581bc..40f49ba305 100644 --- a/packages/babel-core/src/transformation/file/index.js +++ b/packages/babel-core/src/transformation/file/index.js @@ -78,9 +78,6 @@ export default class File { }, }; - this.dynamicImportTypes = {}; - this.dynamicImportIds = {}; - this.dynamicImports = []; this.declarations = {}; this.usedHelpers = {}; @@ -98,9 +95,6 @@ export default class File { pluginPasses: Array>; parserOpts: BabelParserOptions; opts: Object; - dynamicImportTypes: Object; - dynamicImportIds: Object; - dynamicImports: Array; declarations: Object; usedHelpers: Object; path: NodePath; From 655d1cc91bd6816388a932cd481283921fbdd855 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 29 Sep 2017 11:44:16 -0700 Subject: [PATCH 4/8] Remove unused 'usedHelpers' property. --- packages/babel-core/src/transformation/file/index.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/babel-core/src/transformation/file/index.js b/packages/babel-core/src/transformation/file/index.js index 40f49ba305..1a2d1627ec 100644 --- a/packages/babel-core/src/transformation/file/index.js +++ b/packages/babel-core/src/transformation/file/index.js @@ -67,7 +67,6 @@ export default class File { } this.metadata = { - usedHelpers: [], marked: [], modules: { imports: [], @@ -79,7 +78,6 @@ export default class File { }; this.declarations = {}; - this.usedHelpers = {}; this.path = null; this.ast = {}; @@ -96,7 +94,6 @@ export default class File { parserOpts: BabelParserOptions; opts: Object; declarations: Object; - usedHelpers: Object; path: NodePath; ast: Object; scope: Scope; @@ -191,11 +188,6 @@ export default class File { const declar = this.declarations[name]; if (declar) return declar; - if (!this.usedHelpers[name]) { - this.metadata.usedHelpers.push(name); - this.usedHelpers[name] = true; - } - const generator = this.get("helperGenerator"); const runtime = this.get("helpersNamespace"); if (generator) { From 8339e036bfe5fdd3f8ba2791de5456fd259dfda6 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 29 Sep 2017 11:44:32 -0700 Subject: [PATCH 5/8] Remove babel.analyse and surrounding helpers. --- packages/babel-core/src/index.js | 1 - .../src/transformation/file/index.js | 1 - .../babel-core/src/transformation/index.js | 15 +-------- packages/babel-core/test/api.js | 32 ------------------- packages/babel-traverse/src/path/index.js | 8 ----- 5 files changed, 1 insertion(+), 56 deletions(-) diff --git a/packages/babel-core/src/index.js b/packages/babel-core/src/index.js index 7df67c775b..fe616d5260 100644 --- a/packages/babel-core/src/index.js +++ b/packages/babel-core/src/index.js @@ -31,7 +31,6 @@ export function Plugin(alias) { export { transform, - analyse, transformFromAst, transformFile, transformFileSync, diff --git a/packages/babel-core/src/transformation/file/index.js b/packages/babel-core/src/transformation/file/index.js index 1a2d1627ec..f8b833d910 100644 --- a/packages/babel-core/src/transformation/file/index.js +++ b/packages/babel-core/src/transformation/file/index.js @@ -67,7 +67,6 @@ export default class File { } this.metadata = { - marked: [], modules: { imports: [], exports: { diff --git a/packages/babel-core/src/transformation/index.js b/packages/babel-core/src/transformation/index.js index a0b1db373e..b6d3de6a06 100644 --- a/packages/babel-core/src/transformation/index.js +++ b/packages/babel-core/src/transformation/index.js @@ -1,23 +1,10 @@ -/* global BabelFileResult, BabelFileMetadata */ +/* global BabelFileResult */ import fs from "fs"; import * as t from "babel-types"; import File from "./file"; import loadConfig from "../config"; -export function analyse( - code: string, - opts: Object = {}, - visitor?: Object, -): ?BabelFileMetadata { - opts.code = false; - if (visitor) { - opts.plugins = opts.plugins || []; - opts.plugins.push({ visitor }); - } - return transform(code, opts).metadata; -} - export function transform(code: string, opts?: Object): BabelFileResult { const config = loadConfig(opts); if (config === null) return null; diff --git a/packages/babel-core/test/api.js b/packages/babel-core/test/api.js index 2be88b495a..3ca191eb44 100644 --- a/packages/babel-core/test/api.js +++ b/packages/babel-core/test/api.js @@ -103,38 +103,6 @@ describe("parser and generator options", function() { }); describe("api", function() { - it("analyze", function() { - assert.equal(babel.analyse("foobar;").marked.length, 0); - - assert.equal( - babel.analyse("foobar;", { - plugins: [ - new Plugin({ - visitor: { - Program: function(path) { - path.mark("category", "foobar"); - }, - }, - }), - ], - }).marked[0].message, - "foobar", - ); - - assert.equal( - babel.analyse( - "foobar;", - {}, - { - Program: function(path) { - path.mark("category", "foobar"); - }, - }, - ).marked[0].message, - "foobar", - ); - }); - it("exposes the resolvePlugin method", function() { assert.throws( () => babel.resolvePlugin("nonexistent-plugin"), diff --git a/packages/babel-traverse/src/path/index.js b/packages/babel-traverse/src/path/index.js index 43725fc344..5c835cb1f0 100644 --- a/packages/babel-traverse/src/path/index.js +++ b/packages/babel-traverse/src/path/index.js @@ -126,14 +126,6 @@ export default class NodePath { traverse(this.node, visitor, this.scope, state, this); } - mark(type: string, message: string) { - this.hub.file.metadata.marked.push({ - type, - message, - loc: this.node.loc, - }); - } - set(key: string, node: Object) { t.validate(this.node, key, node); this.node[key] = node; From 3bac67b4b90b2cbbea0dd44d283234ce35776f57 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 29 Sep 2017 12:30:30 -0700 Subject: [PATCH 6/8] Remove the resolveModuleSource options. --- packages/babel-core/README.md | 1 - .../babel-core/src/config/option-manager.js | 6 +-- packages/babel-core/src/config/removed.js | 5 +++ .../src/transformation/file/index.js | 6 +-- packages/babel-core/test/api.js | 37 ------------------- .../src/import-builder.js | 8 +--- 6 files changed, 12 insertions(+), 51 deletions(-) diff --git a/packages/babel-core/README.md b/packages/babel-core/README.md index a176d469a5..719f1c856a 100644 --- a/packages/babel-core/README.md +++ b/packages/babel-core/README.md @@ -111,7 +111,6 @@ Following is a table of the options you can use: | `plugins` | `[]` | List of [plugins](https://babeljs.io/docs/plugins/) to load and use | | `presets` | `[]` | List of [presets](https://babeljs.io/docs/plugins/#presets) (a set of plugins) to load and use | | `retainLines` | `false` | Retain line numbers. This will lead to wacky code but is handy for scenarios where you can't use source maps. (**NOTE:** This will not retain the columns) | -| `resolveModuleSource` | `null` | Resolve a module source ie. `import "SOURCE";` to a custom value. Called as `resolveModuleSource(source, filename)` | | `shouldPrintComment` | `null` | An optional callback that controls whether a comment should be output or not. Called as `shouldPrintComment(commentContents)`. **NOTE:** This overrides the `comment` option when used | | `sourceFileName` | `(filenameRelative)` | Set `sources[0]` on returned source map | | `sourceMaps` | `false` | If truthy, adds a `map` property to returned output. If set to `"inline"`, a comment with a sourceMappingURL directive is added to the bottom of the returned code. If set to `"both"` then a `map` property is returned as well as a source map comment appended. **This does not emit sourcemap files by itself!** To have sourcemaps emitted using the CLI, you must pass it the `--source-maps` option | diff --git a/packages/babel-core/src/config/option-manager.js b/packages/babel-core/src/config/option-manager.js index 6bd6757080..ab614ac93d 100644 --- a/packages/babel-core/src/config/option-manager.js +++ b/packages/babel-core/src/config/option-manager.js @@ -57,7 +57,6 @@ const optionNames = new Set([ "sourceType", "auxiliaryCommentBefore", "auxiliaryCommentAfter", - "resolveModuleSource", "getModuleId", "moduleRoot", "moduleIds", @@ -450,9 +449,10 @@ function normalizeOptions(config) { // check for an unknown option if (!optionNames.has(key)) { if (removed[key]) { + const { message, version = 5 } = removed[key]; + throw new ReferenceError( - `Using removed Babel 5 option: ${alias}.${key} - ${removed[key] - .message}`, + `Using removed Babel ${version} option: ${alias}.${key} - ${message}`, ); } else { // eslint-disable-next-line max-len diff --git a/packages/babel-core/src/config/removed.js b/packages/babel-core/src/config/removed.js index 751209e8e6..8d441c5fee 100644 --- a/packages/babel-core/src/config/removed.js +++ b/packages/babel-core/src/config/removed.js @@ -56,4 +56,9 @@ export default { whitelist: { message: "Put the specific transforms you want in the `plugins` option", }, + + resolveModuleSource: { + version: 6, + message: "Use `babel-plugin-module-resolver@3`'s 'resolvePath' options", + }, }; diff --git a/packages/babel-core/src/transformation/file/index.js b/packages/babel-core/src/transformation/file/index.js index f8b833d910..e9dccd5a2a 100644 --- a/packages/babel-core/src/transformation/file/index.js +++ b/packages/babel-core/src/transformation/file/index.js @@ -166,11 +166,9 @@ export default class File { } } + // TODO: Remove this before 7.x's official release. Leaving it in for now to + // prevent unnecessary breakage between beta versions. resolveModuleSource(source: string): string { - const resolveModuleSource = this.opts.resolveModuleSource; - if (resolveModuleSource) { - source = resolveModuleSource(source, this.opts.filename); - } return source; } diff --git a/packages/babel-core/test/api.js b/packages/babel-core/test/api.js index 3ca191eb44..e703d87140 100644 --- a/packages/babel-core/test/api.js +++ b/packages/babel-core/test/api.js @@ -484,26 +484,6 @@ describe("api", function() { }); }), - transformAsync('import localName from "./array";', { - resolveModuleSource: function() { - return "override-source"; - }, - }).then(function(result) { - assert.deepEqual(result.metadata.modules.imports, [ - { - source: "override-source", - imported: ["default"], - specifiers: [ - { - kind: "named", - imported: "default", - local: "localName", - }, - ], - }, - ]); - }), - transformAsync('export * as externalName1 from "external";', { plugins: [require("../../babel-plugin-syntax-export-extensions")], }).then(function(result) { @@ -748,23 +728,6 @@ describe("api", function() { }); }); - it("resolveModuleSource option", function() { - /* eslint-disable max-len */ - const actual = - 'import foo from "foo-import-default";\nimport "foo-import-bare";\nexport { foo } from "foo-export-named";'; - const expected = - 'import foo from "resolved/foo-import-default";\nimport "resolved/foo-import-bare";\nexport { foo } from "resolved/foo-export-named";'; - /* eslint-enable max-len */ - - return transformAsync(actual, { - resolveModuleSource: function(originalSource) { - return "resolved/" + originalSource; - }, - }).then(function(result) { - assert.equal(result.code.trim(), expected); - }); - }); - describe("buildExternalHelpers", function() { describe("smoke tests", function() { it("builds external helpers in global output type", function() { diff --git a/packages/babel-helper-module-imports/src/import-builder.js b/packages/babel-helper-module-imports/src/import-builder.js index bbde6fdef9..0eda1c8663 100644 --- a/packages/babel-helper-module-imports/src/import-builder.js +++ b/packages/babel-helper-module-imports/src/import-builder.js @@ -26,21 +26,17 @@ export default class ImportBuilder { } import() { - const importedSource = this._file.resolveModuleSource(this._importedSource); - this._statements.push( - t.importDeclaration([], t.stringLiteral(importedSource)), + t.importDeclaration([], t.stringLiteral(this._importedSource)), ); return this; } require() { - const importedSource = this._file.resolveModuleSource(this._importedSource); - this._statements.push( t.expressionStatement( t.callExpression(t.identifier("require"), [ - t.stringLiteral(importedSource), + t.stringLiteral(this._importedSource), ]), ), ); From f20f8b164f225a3c854ddbf9651b16a515082dd7 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 29 Sep 2017 11:46:52 -0700 Subject: [PATCH 7/8] Remove unused module metadata collection. --- .../babel-core/src/config/option-manager.js | 2 - packages/babel-core/src/config/removed.js | 6 + .../src/transformation/file/index.js | 32 +--- .../src/transformation/file/metadata.js | 140 --------------- packages/babel-core/test/api.js | 169 ------------------ 5 files changed, 8 insertions(+), 341 deletions(-) delete mode 100644 packages/babel-core/src/transformation/file/metadata.js diff --git a/packages/babel-core/src/config/option-manager.js b/packages/babel-core/src/config/option-manager.js index ab614ac93d..7c7289889d 100644 --- a/packages/babel-core/src/config/option-manager.js +++ b/packages/babel-core/src/config/option-manager.js @@ -41,7 +41,6 @@ const optionNames = new Set([ "ignore", "only", "code", - "metadata", "ast", "extends", "comments", @@ -562,7 +561,6 @@ function createInitialOptions() { babelrc: true, filename: "unknown", code: true, - metadata: true, ast: true, comments: true, compact: "auto", diff --git a/packages/babel-core/src/config/removed.js b/packages/babel-core/src/config/removed.js index 8d441c5fee..e4205bf31e 100644 --- a/packages/babel-core/src/config/removed.js +++ b/packages/babel-core/src/config/removed.js @@ -61,4 +61,10 @@ export default { version: 6, message: "Use `babel-plugin-module-resolver@3`'s 'resolvePath' options", }, + + metadata: { + version: 6, + message: + "Generated plugin metadata is always included in the output result", + }, }; diff --git a/packages/babel-core/src/transformation/file/index.js b/packages/babel-core/src/transformation/file/index.js index e9dccd5a2a..2797f68b95 100644 --- a/packages/babel-core/src/transformation/file/index.js +++ b/packages/babel-core/src/transformation/file/index.js @@ -1,7 +1,6 @@ /* global BabelFileResult, BabelParserOptions, BabelFileMetadata */ import getHelper from "babel-helpers"; -import * as metadataVisitor from "./metadata"; import convertSourceMap from "convert-source-map"; import PluginPass from "../plugin-pass"; import { NodePath, Hub, Scope } from "babel-traverse"; @@ -66,16 +65,7 @@ export default class File { } } - this.metadata = { - modules: { - imports: [], - exports: { - exported: [], - specifiers: [], - }, - }, - }; - + this.metadata = {}; this.declarations = {}; this.path = null; @@ -109,19 +99,6 @@ export default class File { return this._map.get(key); } - getMetadata() { - let has = false; - for (const node of (this.ast.program.body: Array)) { - if (t.isModuleDeclaration(node)) { - has = true; - break; - } - } - if (has) { - this.path.traverse(metadataVisitor, this); - } - } - getModuleName(): ?string { const opts = this.opts; if (!opts.moduleIds) { @@ -332,7 +309,6 @@ export default class File { }).setContext(); this.scope = this.path.scope; this.ast = ast; - this.getMetadata(); } addAst(ast) { @@ -458,7 +434,7 @@ export default class File { makeResult({ code, map, ast, ignored }: BabelFileResult): BabelFileResult { const result = { - metadata: null, + metadata: this.metadata, options: this.opts, ignored: !!ignored, code: null, @@ -474,10 +450,6 @@ export default class File { result.ast = ast; } - if (this.opts.metadata) { - result.metadata = this.metadata; - } - return result; } diff --git a/packages/babel-core/src/transformation/file/metadata.js b/packages/babel-core/src/transformation/file/metadata.js deleted file mode 100644 index 5fcb0efa79..0000000000 --- a/packages/babel-core/src/transformation/file/metadata.js +++ /dev/null @@ -1,140 +0,0 @@ -import * as t from "babel-types"; - -export const ModuleDeclaration = { - enter(path, file) { - const { node } = path; - if (node.source) { - node.source.value = file.resolveModuleSource(node.source.value); - } - }, -}; - -export const ImportDeclaration = { - exit(path, file) { - const { node } = path; - - const specifiers = []; - const imported = []; - file.metadata.modules.imports.push({ - source: node.source.value, - imported, - specifiers, - }); - - for (const specifier of (path.get("specifiers"): Array)) { - const local = specifier.node.local.name; - - if (specifier.isImportDefaultSpecifier()) { - imported.push("default"); - specifiers.push({ - kind: "named", - imported: "default", - local, - }); - } - - if (specifier.isImportSpecifier()) { - const importedName = specifier.node.imported.name; - imported.push(importedName); - specifiers.push({ - kind: "named", - imported: importedName, - local, - }); - } - - if (specifier.isImportNamespaceSpecifier()) { - imported.push("*"); - specifiers.push({ - kind: "namespace", - local, - }); - } - } - }, -}; - -export function ExportDeclaration(path, file) { - const { node } = path; - - const source = node.source ? node.source.value : null; - const exports = file.metadata.modules.exports; - - // export function foo() {} - // export let foo = "bar"; - const declar = path.get("declaration"); - if (declar.isStatement()) { - const bindings = declar.getBindingIdentifiers(); - - for (const name in bindings) { - exports.exported.push(name); - exports.specifiers.push({ - kind: "local", - local: name, - exported: path.isExportDefaultDeclaration() ? "default" : name, - }); - } - } - - if (path.isExportNamedDeclaration() && node.specifiers) { - for (const specifier of (node.specifiers: Array)) { - const exported = specifier.exported.name; - exports.exported.push(exported); - - // export foo from "bar"; - if (t.isExportDefaultSpecifier(specifier)) { - exports.specifiers.push({ - kind: "external", - local: exported, - exported, - source, - }); - } - - // export * as foo from "bar"; - if (t.isExportNamespaceSpecifier(specifier)) { - exports.specifiers.push({ - kind: "external-namespace", - exported, - source, - }); - } - - const local = specifier.local; - if (!local) continue; - - // export { foo } from "bar"; - // export { foo as bar } from "bar"; - if (source) { - exports.specifiers.push({ - kind: "external", - local: local.name, - exported, - source, - }); - } - - // export { foo }; - // export { foo as bar }; - if (!source) { - exports.specifiers.push({ - kind: "local", - local: local.name, - exported, - }); - } - } - } - - // export * from "bar"; - if (path.isExportAllDeclaration()) { - exports.specifiers.push({ - kind: "external-all", - source, - }); - } -} - -export function Scope(path) { - path.skip(); -} diff --git a/packages/babel-core/test/api.js b/packages/babel-core/test/api.js index e703d87140..b9c0f76d4d 100644 --- a/packages/babel-core/test/api.js +++ b/packages/babel-core/test/api.js @@ -434,175 +434,6 @@ describe("api", function() { }); }); - it("modules metadata", function() { - return Promise.all([ - // eslint-disable-next-line max-len - transformAsync( - 'import { externalName as localName } from "external";', - ).then(function(result) { - assert.deepEqual(result.metadata.modules.imports[0], { - source: "external", - imported: ["externalName"], - specifiers: [ - { - kind: "named", - imported: "externalName", - local: "localName", - }, - ], - }); - }), - - transformAsync('import * as localName2 from "external";').then(function( - result, - ) { - assert.deepEqual(result.metadata.modules.imports[0], { - source: "external", - imported: ["*"], - specifiers: [ - { - kind: "namespace", - local: "localName2", - }, - ], - }); - }), - - transformAsync('import localName3 from "external";').then(function( - result, - ) { - assert.deepEqual(result.metadata.modules.imports[0], { - source: "external", - imported: ["default"], - specifiers: [ - { - kind: "named", - imported: "default", - local: "localName3", - }, - ], - }); - }), - - transformAsync('export * as externalName1 from "external";', { - plugins: [require("../../babel-plugin-syntax-export-extensions")], - }).then(function(result) { - assert.deepEqual(result.metadata.modules.exports, { - exported: ["externalName1"], - specifiers: [ - { - kind: "external-namespace", - exported: "externalName1", - source: "external", - }, - ], - }); - }), - - transformAsync('export externalName2 from "external";', { - plugins: [require("../../babel-plugin-syntax-export-extensions")], - }).then(function(result) { - assert.deepEqual(result.metadata.modules.exports, { - exported: ["externalName2"], - specifiers: [ - { - kind: "external", - local: "externalName2", - exported: "externalName2", - source: "external", - }, - ], - }); - }), - - transformAsync("export function namedFunction() {}").then(function( - result, - ) { - assert.deepEqual(result.metadata.modules.exports, { - exported: ["namedFunction"], - specifiers: [ - { - kind: "local", - local: "namedFunction", - exported: "namedFunction", - }, - ], - }); - }), - - transformAsync('export var foo = "bar";').then(function(result) { - assert.deepEqual(result.metadata.modules.exports, { - exported: ["foo"], - specifiers: [ - { - kind: "local", - local: "foo", - exported: "foo", - }, - ], - }); - }), - - transformAsync("export { localName as externalName3 };").then(function( - result, - ) { - assert.deepEqual(result.metadata.modules.exports, { - exported: ["externalName3"], - specifiers: [ - { - kind: "local", - local: "localName", - exported: "externalName3", - }, - ], - }); - }), - - transformAsync('export { externalName4 } from "external";').then(function( - result, - ) { - assert.deepEqual(result.metadata.modules.exports, { - exported: ["externalName4"], - specifiers: [ - { - kind: "external", - local: "externalName4", - exported: "externalName4", - source: "external", - }, - ], - }); - }), - - transformAsync('export * from "external";').then(function(result) { - assert.deepEqual(result.metadata.modules.exports, { - exported: [], - specifiers: [ - { - kind: "external-all", - source: "external", - }, - ], - }); - }), - - transformAsync( - "export default function defaultFunction() {}", - ).then(function(result) { - assert.deepEqual(result.metadata.modules.exports, { - exported: ["defaultFunction"], - specifiers: [ - { - kind: "local", - local: "defaultFunction", - exported: "default", - }, - ], - }); - }), - ]); - }); - it("ignore option", function() { return Promise.all([ transformAsync("", { From a390a92d6a8e16a5cfc92a4163c8cac64d789860 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 29 Sep 2017 12:39:29 -0700 Subject: [PATCH 8/8] Remove unused helpers prop. --- packages/babel-core/src/transformation/file/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/babel-core/src/transformation/file/index.js b/packages/babel-core/src/transformation/file/index.js index 2797f68b95..b827c4b0bc 100644 --- a/packages/babel-core/src/transformation/file/index.js +++ b/packages/babel-core/src/transformation/file/index.js @@ -77,8 +77,6 @@ export default class File { this.hub = new Hub(this); } - static helpers: Array; - pluginPasses: Array>; parserOpts: BabelParserOptions; opts: Object;