Skip to content

Commit

Permalink
feat(babel): export * as ns support (#511)
Browse files Browse the repository at this point in the history
* declares export * as ns support

* check rollup version

* oof

* refactor: get rollupVersion from this.meta in options hook
  • Loading branch information
JLHwung committed Aug 3, 2020
1 parent 621768b commit 5fa1559
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions packages/babel/src/index.js
Expand Up @@ -29,7 +29,7 @@ const unpackOptions = ({
};
};

const unpackInputPluginOptions = ({ skipPreflightCheck = false, ...rest }) => {
const unpackInputPluginOptions = ({ skipPreflightCheck = false, ...rest }, rollupVersion) => {
if (!rest.babelHelpers) {
// eslint-disable-next-line no-console
console.warn(
Expand All @@ -45,6 +45,8 @@ const unpackInputPluginOptions = ({ skipPreflightCheck = false, ...rest }) => {
supportsStaticESM: true,
supportsDynamicImport: true,
supportsTopLevelAwait: true,
// todo: remove version checks for 1.20 - 1.25 when we bump peer deps
supportsExportNamespaceFrom: !rollupVersion.match(/^1\.2[0-5]\./),
...rest.caller
}
});
Expand Down Expand Up @@ -90,22 +92,30 @@ function createBabelInputPluginFactory(customCallback = returnObject) {
overrides
);

const {
exclude,
extensions,
babelHelpers,
include,
skipPreflightCheck,
...babelOptions
} = unpackInputPluginOptions(pluginOptionsWithOverrides);

const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
const includeExcludeFilter = createFilter(include, exclude);
const filter = (id) => extensionRegExp.test(id) && includeExcludeFilter(id);

let babelHelpers, babelOptions, filter, skipPreflightCheck;
return {
name: 'babel',

options() {
//todo: remove options hook and hoist declarations when version checks are removed
let exclude, include, extensions;

({
exclude,
extensions,
babelHelpers,
include,
skipPreflightCheck,
...babelOptions
} = unpackInputPluginOptions(pluginOptionsWithOverrides, this.meta.rollupVersion));

const extensionRegExp = new RegExp(`(${extensions.map(escapeRegExpCharacters).join('|')})$`);
const includeExcludeFilter = createFilter(include, exclude);
filter = (id) => extensionRegExp.test(id) && includeExcludeFilter(id);

return null;
},

resolveId(id) {
if (id !== HELPERS) {
return null;
Expand Down

0 comments on commit 5fa1559

Please sign in to comment.