-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Rollup supports producing multiple bundles at once by exporting multiple configs in an array from the rollup config script, e.g.
import livereload from "rollup-plugin-livereload";
export default [{
{
input: `modA/src/main.js`,
output: {
sourcemap: true,
format: "iife",
name: "app",
file: `modA/public/build/bundle.js`
},
plugins: [
livereload("modA/public"),
]
}
},{
{
input: `modB/src/main.js`,
output: {
sourcemap: true,
format: "iife",
name: "app",
file: `modB/public/build/bundle.js`
},
plugins: [
livereload("modB/public"),
]
}
}]Using this rollup feature however breaks this plugin. The livereload server is kept in a global state variable PLUGIN_LIVERELOAD
rollup-plugin-livereload/src/index.js
Lines 5 to 7 in 0f0b30c
| const state = (global.PLUGIN_LIVERELOAD = global.PLUGIN_LIVERELOAD || { | |
| server: null, | |
| }) |
If livereload is instantiated multiple times in the same rollup process, they clash and the variable will be overwritten.
When reloading the rollup config, this leads to multiple livereload instances trying to close the same server
rollup-plugin-livereload/src/index.js
Lines 20 to 22 in 0f0b30c
| if (state.server) { | |
| state.server.close() | |
| } |
which results in a crash, as closing the same server multiple times is not supported by
livereload
[!] TypeError: Cannot read properties of null (reading 'close')
at Server.close (PROJECT\node_modules\livereload\lib\livereload.js:227:27)
at livereload (PROJECT\node_modules\rollup-plugin-livereload\dist\index.cjs.js:104:18)
at constructConfig (file:///PROJECT/rollup.config.mjs?1683999555521:92:28)
at file:///PROJECT/rollup.config.mjs?1683999555521:109:5
at ModuleJob.run (node:internal/modules/esm/module_job:194:25
Metadata
Metadata
Assignees
Labels
No labels