Skip to content

Commit

Permalink
chore: add extra unambiguous sources when env is rollup/standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Dec 2, 2019
1 parent 12c0efb commit eedddce
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions babel.config.js
Expand Up @@ -15,20 +15,41 @@ module.exports = function(api) {
let convertESM = true;
let ignoreLib = true;
const nodeVersion = "6.9";
// The vast majority of our src files are modules, but we use
// unambiguous to keep things simple until we get around to renaming
// the modules to be more easily distinguished from CommonJS
const unambiguousSources = [
"packages/*/src",
"packages/*/test",
"codemods/*/src",
"codemods/*/test",
"eslint/*/src",
"eslint/*/test",
];

switch (env) {
// Configs used during bundling builds.
case "rollup":
convertESM = false;
ignoreLib = false;
// rollup-commonjs will converts node_modules to ESM
unambiguousSources.push(
"**/node_modules",
// todo: remove this after it is rewritten into ESM
"packages/babel-preset-env/data"
);
envOpts.targets = {
node: nodeVersion,
};
break;
case "standalone":
convertESM = false;
ignoreLib = false;
// targets to default browserslist
unambiguousSources.push(
"**/node_modules",
"packages/babel-preset-env/data"
);
// targets to browserslists: defaults
break;
case "production":
// Config during builds before publish.
Expand All @@ -55,7 +76,6 @@ module.exports = function(api) {
// and then mark actual modules as modules farther down.
sourceType: "script",
comments: false,
exclude: "**/node_modules/**",
ignore: [
// These may not be strictly necessary with the newly-limited scope of
// babelrc searching, but including them for now because we had them
Expand Down Expand Up @@ -104,19 +124,7 @@ module.exports = function(api) {
presets: [["@babel/env", envOptsNoTargets]],
},
{
// The vast majority of our src files are modules, but we use
// unambiguous to keep things simple until we get around to renaming
// the modules to be more easily distinguished from CommonJS
test: [
"packages/*/src",
"packages/*/test",
"codemods/*/src",
"codemods/*/test",
"eslint/*/src",
"eslint/*/test",
"**/node_modules",
"packages/babel-preset-env/data",
],
test: unambiguousSources,
sourceType: "unambiguous",
},
].filter(Boolean),
Expand Down

0 comments on commit eedddce

Please sign in to comment.