Issue 1:
Question 1

I find that there are many unnecessary duplications in the (webpack) bundle (output)result, to be specific, they all are the helpers(like classCheck, objectSpread(due to the object-spread plugin).

So, I want to reduce the duplications. If it's a library, sure, I will use transform-runtime plugin(refer to runtime-corejs3) to do this. But now this is an application, so, what's the correct way to do this?

Therefor I'm getting confused because the transfrom-runtime plugin is recommended for library(and is for the whole reduction. i.e. core-js, regenerator and the helpers). But here I just want to reduce the helper duplications, not others duplications because that has been done by preset/env.

So here the question I want to ask/discuss is that is it necessary to reduce the helpers duplications in an application, if yes, and how?

Question 2

The other question is, core-js/modules/es.promise.js and core-js-pure/modules/es.promise.js are exactly the same code, the main difference just is that the former has global pollution? If so, why core-js doesn't use(directly import) core-js-pure to polyfill and then add it to global? IMO, this will greatly reduce the duplications because at now the libs use transform-runtime(finally core-js-pure) but apps use preset-env(finally core-js), there is no shared/shareable codes between apps and libs, right?

Issue 2:
Bug Report

Current Behavior

@babel/traverse tries to throw a Duplicate declaration error for key duplicates in different ambient module declarations in one file. @babel/parser with typescript plugin is used to build an AST.

#4640 explains why Cannot read property 'file' of undefined is thrown.

Input Code

const parse = require('@babel/parser').parse;
const traverse = require('@babel/traverse').default;

const code = `
declare module 'module1' {
export const variable: string;
}

declare module 'module2' {
export const variable: number;
}
`;

const ast = parse(code, {
sourceType: 'module',
plugins: ['typescript']
});

traverse(ast, {
enter(path) {
// smth
}
});

Output

...\node_modules\@babel\traverse\lib\scope\index.js:347
throw this.hub.file.buildCodeFrameError(id, `Duplicate declaration "${name}"`, TypeError);
^

TypeError: Cannot read property 'file' of undefined
at Scope.checkBlockScopedCollisions (...\node_modules\@babel\traverse\lib\scope\index.js:347:22)
at Scope.registerBinding (...\node_modules\@babel\traverse\lib\scope\index.js:506:16)
at Scope.registerDeclaration (...\node_modules\@babel\traverse\lib\scope\index.js:454:14)
at Object.Declaration (...\node_modules\@babel\traverse\lib\scope\index.js:125:12)
at NodePath._call (...\node_modules\@babel\traverse\lib\path\context.js:53:20)
at NodePath.call (...\node_modules\@babel\traverse\lib\path\context.js:40:17)
at NodePath.visit (...\node_modules\@babel\traverse\lib\path\context.js:88:12)
at TraversalContext.visitQueue (...\node_modules\@babel\traverse\lib\context.js:118:16)
at TraversalContext.visitMultiple (...\node_modules\@babel\traverse\lib\context.js:85:17)
at TraversalContext.visit (...\node_modules\@babel\traverse\lib\context.js:144:19)

Expected behavior

Each module declaration has its own block scope, so the Duplicate declaration error shouldn't be thrown.

Environment

Babel version: v7.0.0-beta.51

Node/npm version: node 8.11.3 / npm 5.6.0

OS: Windows 10