Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also remove export-all declarations when not tree-shaking #3209

Merged
merged 1 commit into from Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/ast/nodes/ExportAllDeclaration.ts
@@ -1,8 +1,11 @@
import MagicString from 'magic-string';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
import Literal from './Literal';
import * as NodeType from './NodeType';
import { NodeBase } from './shared/Node';

export default class ExportAllDeclaration extends NodeBase {
needsBoundaries!: true;
source!: Literal<string>;
type!: NodeType.tExportAllDeclaration;

Expand All @@ -13,4 +16,13 @@ export default class ExportAllDeclaration extends NodeBase {
initialise() {
this.context.addExport(this);
}

render(code: MagicString, _options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) {
code.remove(
(nodeRenderOptions as NodeRenderOptions).start as number,
(nodeRenderOptions as NodeRenderOptions).end as number
);
}
}

ExportAllDeclaration.prototype.needsBoundaries = true;
1 change: 1 addition & 0 deletions test/form/samples/no-treeshake/_expected/amd.js
Expand Up @@ -47,6 +47,7 @@ define(['exports', 'external'], function (exports, external) { 'use strict';

exports.create = create;
exports.getPrototypeOf = getPrototypeOf;
exports.quux = quux;
exports.strange = quux;

Object.defineProperty(exports, '__esModule', { value: true });
Expand Down
1 change: 1 addition & 0 deletions test/form/samples/no-treeshake/_expected/cjs.js
Expand Up @@ -51,4 +51,5 @@ test({

exports.create = create;
exports.getPrototypeOf = getPrototypeOf;
exports.quux = quux;
exports.strange = quux;
2 changes: 1 addition & 1 deletion test/form/samples/no-treeshake/_expected/es.js
Expand Up @@ -45,4 +45,4 @@ test({
}
});

export { create, getPrototypeOf, quux as strange };
export { create, getPrototypeOf, quux, quux as strange };
1 change: 1 addition & 0 deletions test/form/samples/no-treeshake/_expected/iife.js
Expand Up @@ -48,6 +48,7 @@ var stirred = (function (exports, external) {

exports.create = create;
exports.getPrototypeOf = getPrototypeOf;
exports.quux = quux;
exports.strange = quux;

return exports;
Expand Down
1 change: 1 addition & 0 deletions test/form/samples/no-treeshake/_expected/umd.js
Expand Up @@ -51,6 +51,7 @@

exports.create = create;
exports.getPrototypeOf = getPrototypeOf;
exports.quux = quux;
exports.strange = quux;

Object.defineProperty(exports, '__esModule', { value: true });
Expand Down
2 changes: 2 additions & 0 deletions test/form/samples/no-treeshake/main.js
@@ -1,6 +1,8 @@
import * as external from 'external';
import foo from './foo.js';

export { quux as strange } from './quux.js';
export * from './quux.js';

function baz() {
return foo + external.value;
Expand Down