Allow babel-plugin/preset to be in package names outside the prefix, when used in a scope. (#8473)
This commit is contained in:
parent
5043ec78bc
commit
ffa8e6cbae
@ -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 {
|
||||
|
||||
3
packages/babel-core/test/fixtures/resolution/foo-org-paths/node_modules/@foo/thing-babel-plugin/index.js
generated
vendored
Normal file
3
packages/babel-core/test/fixtures/resolution/foo-org-paths/node_modules/@foo/thing-babel-plugin/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
3
packages/babel-core/test/fixtures/resolution/foo-org-paths/node_modules/@foo/thing-babel-preset/index.js
generated
vendored
Normal file
3
packages/babel-core/test/fixtures/resolution/foo-org-paths/node_modules/@foo/thing-babel-preset/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
3
packages/babel-core/test/fixtures/resolution/foo-org-paths/node_modules/@foo/thing.babel-plugin-convert/index.js
generated
vendored
Normal file
3
packages/babel-core/test/fixtures/resolution/foo-org-paths/node_modules/@foo/thing.babel-plugin-convert/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
3
packages/babel-core/test/fixtures/resolution/foo-org-paths/node_modules/@foo/thing.babel-preset-convert/index.js
generated
vendored
Normal file
3
packages/babel-core/test/fixtures/resolution/foo-org-paths/node_modules/@foo/thing.babel-preset-convert/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -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");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user