Skip to content

Commit

Permalink
Fix standalone bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 18, 2020
1 parent f7614f1 commit c574765
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* eslint-disable @babel/development/plugin-name */

export { default } from "@babel/plugin-transform-react-jsx/lib/development";
export { default } from "@babel/plugin-transform-react-jsx/lib/development.js";
20 changes: 10 additions & 10 deletions scripts/rollup-plugin-babel-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ module.exports = function () {
);
}

const matches = importee.match(/^@babel\/([^/]+)$/);
const matches = importee.match(
/^@babel\/(?<pkg>[^/]+)(?:\/lib\/(?<internal>.*?))?$/
);
if (!matches) return null;
const { pkg, internal } = matches.groups;

// resolve babel package names to their src index file
const packageFolder = path.join(
dirname,
"packages",
`babel-${matches[1]}`
);
const packageFolder = path.join(dirname, "packages", `babel-${pkg}`);

let packageJsonSource;
try {
Expand All @@ -76,10 +75,11 @@ module.exports = function () {

const packageJson = JSON.parse(packageJsonSource);

const filename =
typeof packageJson["browser"] === "string"
? packageJson["browser"]
: packageJson["main"];
const filename = internal
? `src/${internal}`
: typeof packageJson["browser"] === "string"
? packageJson["browser"]
: packageJson["main"];

const asJS = path.normalize(
path.join(
Expand Down

0 comments on commit c574765

Please sign in to comment.