Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strip rollup-plugin prefix to find named plugin exports, throw when e…
…xport cannot be found (#3647) * Strip rollup-plugin prefix to find named plugin exports, throw when export cannot be found * Also ignore anything after the first "." * Update dependencies * Cover more cases
- Loading branch information
1 parent
981b11c
commit b8013f8
Showing
19 changed files
with
118 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { assertIncludes } = require('../../../../utils.js'); | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
description: 'Throws when the plugin export cannot be found', | ||
skipIfWindows: true, | ||
command: `echo 'console.log("ignored");' | rollup -p "./my-missing-plugin"`, | ||
error(err) { | ||
assertIncludes( | ||
err.message, | ||
`[!] Error: Cannot find entry for plugin "${path.join( | ||
__dirname, | ||
'my-missing-plugin' | ||
)}". The plugin needs to export a function either as "default" or "myMissingPlugin" for Rollup to recognize it.` | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('transformed'); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
description: 'supports stripping "rollup-config" prefix to find named plugin export', | ||
skipIfWindows: true, | ||
command: `rollup -c -p rollup-plugin-terser` | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){this.x=t};t.prototype.output=function(){console.log(this.x)},new t(123).output(),exports.Bar=t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var t=function(t){this.x=t};t.prototype.output=function(){console.log(this.x)},new t(123).output();export{t as Bar}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Foo { | ||
constructor(x) { | ||
this.x = x; | ||
} | ||
output() { | ||
console.log(this.x); | ||
} | ||
} | ||
|
||
const foo = new Foo(123); | ||
foo.output(); | ||
export { Foo as Bar }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const buble = require('@rollup/plugin-buble'); | ||
|
||
export default { | ||
input: 'main.js', | ||
plugins: [ | ||
buble() | ||
], | ||
output: [ | ||
{ | ||
file: '_actual/cjs.js', | ||
format: 'cjs' | ||
}, | ||
{ | ||
file: '_actual/es.js', | ||
format: 'esm' | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
description: 'handles plugins where the export name is the camelized file name', | ||
skipIfWindows: true, | ||
command: | ||
`echo 'console.log("initial");' | rollup ` + | ||
'-p "./plugins/my-super-plugin1.js" ' + | ||
'-p "./plugins/rollup-plugin-my-super-plugin2.js" ' + | ||
'-p "./plugins/rollup-plugin-" ' + | ||
'-p "./plugins/@rollup/plugin-supreme"' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
console.log("initial"); | ||
console.log("plugin1"); | ||
console.log("plugin2"); | ||
console.log("plugin3"); | ||
console.log("plugin4"); |
5 changes: 5 additions & 0 deletions
5
test/cli/samples/plugin/relative-camelized/plugins/@rollup/plugin-supreme.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exports.supreme = () => ({ | ||
transform(code) { | ||
return `${code}console.log("plugin4");\n`; | ||
} | ||
}); |
5 changes: 5 additions & 0 deletions
5
test/cli/samples/plugin/relative-camelized/plugins/my-super-plugin1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exports.mySuperPlugin1 = () => ({ | ||
transform(code) { | ||
return `${code}console.log("plugin1");\n`; | ||
} | ||
}); |
5 changes: 5 additions & 0 deletions
5
test/cli/samples/plugin/relative-camelized/plugins/rollup-plugin-
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exports.rollupPlugin = () => ({ | ||
transform(code) { | ||
return `${code}console.log("plugin3");\n`; | ||
} | ||
}); |
5 changes: 5 additions & 0 deletions
5
test/cli/samples/plugin/relative-camelized/plugins/rollup-plugin-my-super-plugin2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exports.mySuperPlugin2 = () => ({ | ||
transform(code) { | ||
return `${code}console.log("plugin2");\n`; | ||
} | ||
}); |