Allow babel-plugin/preset to be in package names outside the prefix, when used in a scope. (#8473)

This commit is contained in:
Logan Smyth 2018-08-16 15:13:52 -07:00 committed by GitHub
parent 5043ec78bc
commit ffa8e6cbae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 2 deletions

View File

@ -15,8 +15,8 @@ const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-plugin(?:-|\/|$)|[^/]+\/)/;
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-preset(?:-|\/|$)|[^/]+\/)/;
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;
const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
export function resolvePlugin(name: string, dirname: string): string | null {

View File

@ -0,0 +1,3 @@
module.exports = function() {
return {};
};

View File

@ -0,0 +1,3 @@
module.exports = function() {
return {};
};

View File

@ -0,0 +1,3 @@
module.exports = function() {
return {};
};

View File

@ -0,0 +1,3 @@
module.exports = function() {
return {};
};

View File

@ -134,6 +134,46 @@ describe("addon resolution", function() {
});
});
it("should find @foo scoped presets with an inner babel-preset", function() {
process.chdir("foo-org-paths");
babel.transform("", {
filename: "filename.js",
babelrc: false,
presets: ["@foo/thing.babel-preset-convert"],
});
});
it("should find @foo scoped plugins with an inner babel-plugin", function() {
process.chdir("foo-org-paths");
babel.transform("", {
filename: "filename.js",
babelrc: false,
plugins: ["@foo/thing.babel-plugin-convert"],
});
});
it("should find @foo scoped presets with an babel-preset suffix", function() {
process.chdir("foo-org-paths");
babel.transform("", {
filename: "filename.js",
babelrc: false,
presets: ["@foo/thing-babel-preset"],
});
});
it("should find @foo scoped plugins with an babel-plugin suffix", function() {
process.chdir("foo-org-paths");
babel.transform("", {
filename: "filename.js",
babelrc: false,
plugins: ["@foo/thing-babel-plugin"],
});
});
it("should find @foo scoped presets with an existing prefix", function() {
process.chdir("foo-org-paths");