Limit file-based plugins/presets to only exporting functions. (#6494)
This commit is contained in:
parent
445b252bc4
commit
1b4307205e
@ -556,6 +556,15 @@ function normalizePair(
|
||||
);
|
||||
}
|
||||
|
||||
if (filepath !== null && typeof value === "object" && value) {
|
||||
// We allow object values for plugins/presets nested directly within a
|
||||
// config object, because it can be useful to define them in nested
|
||||
// configuration contexts.
|
||||
throw new Error(
|
||||
"Plugin/Preset files are not allowed to export objects, only functions.",
|
||||
);
|
||||
}
|
||||
|
||||
if (options != null && typeof options !== "object") {
|
||||
throw new Error(
|
||||
"Plugin/Preset options must be an object, null, or undefined",
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.default = {
|
||||
plugins: [require('../../../../../babel-plugin-syntax-decorators')]
|
||||
module.exports = function() {
|
||||
return {
|
||||
plugins: [require('../../../../../babel-plugin-syntax-decorators')]
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('../../../../../babel-plugin-syntax-decorators'),
|
||||
]
|
||||
module.exports = function() {
|
||||
return {
|
||||
plugins: [
|
||||
require('../../../../../babel-plugin-syntax-decorators'),
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
module.exports = function() {
|
||||
return {};
|
||||
};
|
||||
@ -12,12 +12,14 @@ const main = defineHelper(__dirname, "main", `
|
||||
}
|
||||
`);
|
||||
|
||||
module.exports = {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
module.exports = function() {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -17,12 +17,14 @@ const main = defineHelper(__dirname, "main", `
|
||||
}
|
||||
`);
|
||||
|
||||
module.exports = {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
module.exports = function() {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -8,12 +8,14 @@ const main = defineHelper(__dirname, "main", `
|
||||
}
|
||||
`);
|
||||
|
||||
module.exports = {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
module.exports = function() {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -17,12 +17,14 @@ const main = defineHelper(__dirname, "main", `
|
||||
}
|
||||
`);
|
||||
|
||||
module.exports = {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
module.exports = function() {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -15,12 +15,14 @@ const main = defineHelper(__dirname, "main", `
|
||||
}
|
||||
`);
|
||||
|
||||
module.exports = {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
module.exports = function() {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -14,12 +14,14 @@ const main = defineHelper(__dirname, "main", `
|
||||
}
|
||||
`);
|
||||
|
||||
module.exports = {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
module.exports = function() {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -12,16 +12,18 @@ const main = defineHelper(__dirname, "main", `
|
||||
}
|
||||
`);
|
||||
|
||||
module.exports = {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name === "REPLACE_ME_1") {
|
||||
const mainHelper = this.addHelper(main);
|
||||
path.replaceWith(mainHelper);
|
||||
} else if (path.node.name === "REPLACE_ME_2") {
|
||||
const dependencyHelper = this.addHelper(dependency);
|
||||
path.replaceWith(dependencyHelper);
|
||||
}
|
||||
module.exports = function() {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name === "REPLACE_ME_1") {
|
||||
const mainHelper = this.addHelper(main);
|
||||
path.replaceWith(mainHelper);
|
||||
} else if (path.node.name === "REPLACE_ME_2") {
|
||||
const dependencyHelper = this.addHelper(dependency);
|
||||
path.replaceWith(dependencyHelper);
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -15,12 +15,14 @@ const main = defineHelper(__dirname, "main", `
|
||||
}
|
||||
`);
|
||||
|
||||
module.exports = {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
module.exports = function() {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path) {
|
||||
if (path.node.name !== "REPLACE_ME") return;
|
||||
const helper = this.addHelper(main);
|
||||
path.replaceWith(helper);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user