Skip to content

Commit

Permalink
Don't strip process.env.BABEL_8_BREAKING for local development with r…
Browse files Browse the repository at this point in the history
…ollup
  • Loading branch information
nicolo-ribaudo committed Dec 2, 2020
1 parent 47f2d00 commit a722b3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
15 changes: 8 additions & 7 deletions Gulpfile.js
Expand Up @@ -110,7 +110,7 @@ if (process.env.CIRCLE_PR_NUMBER) {

const babelVersion =
require("./packages/babel-core/package.json").version + versionSuffix;
function buildRollup(packages) {
function buildRollup(packages, targetBrowsers) {
const sourcemap = process.env.NODE_ENV === "production";
return Promise.all(
packages.map(async ({ src, format, dest, name, filename }) => {
Expand Down Expand Up @@ -166,11 +166,12 @@ function buildRollup(packages) {
],
}),
rollupJson(),
rollupNodePolyfills({
sourceMap: sourcemap,
include: "**/*.{js,ts}",
}),
],
targetBrowsers &&
rollupNodePolyfills({
sourceMap: sourcemap,
include: "**/*.{js,ts}",
}),
].filter(Boolean),
});

const outputFile = path.join(src, dest, filename || "index.js");
Expand Down Expand Up @@ -235,7 +236,7 @@ const standaloneBundle = [
];

gulp.task("build-rollup", () => buildRollup(libBundles));
gulp.task("build-babel-standalone", () => buildRollup(standaloneBundle));
gulp.task("build-babel-standalone", () => buildRollup(standaloneBundle, true));

gulp.task("build-babel", () => buildBabel(/* exclude */ libBundles));
gulp.task("build", gulp.parallel("build-rollup", "build-babel"));
Expand Down
7 changes: 6 additions & 1 deletion babel.config.js
Expand Up @@ -119,7 +119,7 @@ module.exports = function (api) {

process.env.STRIP_BABEL_8_FLAG && [
pluginToggleBabel8Breaking,
{ breaking: !!process.env.BABEL_8_BREAKING },
{ breaking: bool(process.env.BABEL_8_BREAKING) },
],
].filter(Boolean),
overrides: [
Expand Down Expand Up @@ -166,6 +166,11 @@ module.exports = function (api) {
return config;
};

// env vars from the cli are always strings, so !!ENV_VAR returns true for "false"
function bool(value) {
return value && value === "false" && value === "0";
}

function pluginToggleBabel8Breaking({ types: t }, { breaking }) {
return {
visitor: {
Expand Down

0 comments on commit a722b3b

Please sign in to comment.