-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recommendation for multi-module setup? Memory leak with 18+ Rollup watchers #177
Comments
You could try using single instance of typescript with multiple instances of the plugin. See const ts = require("typescript");
// ...
[
rpt2_1 ( { typescript: ts } ),
]
// ...
[
rpt2_2 ( { typescript: ts } ),
] Let me know if that helps. If it doesn't consider making a repo with reproduction, I'll see if there is anything on the plugin end that can be doe for this scenario. |
Since You can set up the process I'm working with cloning |
Indeed. Looks like there is a memory leak somewhere. Rollup had a leak in watch mode before, but it seems to be fixed. (rollup/rollup#883) Each instance of the plugin will create it's own instance of You can try running plugin with |
This problem is also bothering me. I have 60+ ui components to build. Actually, I just can build 10 components one time. |
I find way to bypass the problem. Use
const buildChild = (a, b) => {
const cp = require('child_process')
const c1 = cp.spawn('node', ['./build/build.component.js', a, b])
c1.stdout.on('data', function (data) {
spinner.info(`${chalk.blue(data)}`)
})
c1.stderr.on('data', function (data) {
spinner.warn(`${chalk.red(data)}`)
})
c1.on('close', function (code) {
a += 5
b += 5
if (a > pkgs.length && b > pkgs.length) {
spinner.succeed(`${chalk.green('Build done. Exit code ' + code)}`)
return
}
buildChild(a, b)
})
}
const runBuild = async () => {
let index = 0
const pkgs = await getPackages()
const inputs = pkgs
.map(pkg => pkg.name)
.slice(process.argv[2], process.argv[3])
build(inputs[index])
async function build(name) {
const inputOptions = {
input: pathToEntry,
plugins: [
nodeResolve(),
css(),
vue({
target: 'browser',
css: false,
}),
typescript({
tsconfigOverride: {
compilerOptions: {
declaration: false,
},
'exclude': [
'node_modules',
'__tests__',
],
},
abortOnError: false,
}),
],
external(id) {
return /^vue/.test(id)
|| deps.some(k => new RegExp('^' + k).test(id))
},
}
const outOptions = {
format: 'es',
file: [filename],
}
const bundle = await rollup.rollup(inputOptions)
console.log(name, 'done')
await bundle.write(outOptions)
index++
if (index < inputs.length) {
await build(inputs[index])
} else {
console.log('batch done')
}
}
}
runBuild() |
So I'm not sure if there is anything we can really do within rpt2 to resolve this.
The OOM error is also coming from within TS itself, so I'm not sure that it's a memory leak in rpt2 either, if a memory leak at all. It also may have been resolved in newer versions of TS. Really the only thing I could think that we could do with rpt2 is share a Being able to share a As this is high complexity, for a fairly specific use-case, stale, and has a workaround above, I'm going to close this issue for now. If someone is interested in investigating such a feature, we can potentially re-open then. |
I implemented one optimization for watch mode that relates to this in #388 which was released in Between #388 and my above comment, there's really only one more possible optimization for this: avoiding recreating the |
I have a project with a bunch (18) separate (TS) modules, each of which is compiled down to its own
.js
file with rollup and this plugin. I'd like to set up a single rollup process to watch and recompile the lot of them, which I'm currently doing with a rollup config file that instantiates this plugin 18 times, each time with a differentinclude
setting, because otherwise the plugin will emit.d.ts
files for all the files in each project'sdist
directory.This regularly (but only after a bunch of recompile cycles) leads to node running out of memory:
I guess that has something to do with the TypeScript compiler building up its type/code graphs multiple times, once for every instance of the plugin. Is that correct?
Is there a way to set up the plugin once, but use it to build several projects, each of which emits
.d.ts
files only for its own files?Or is there maybe some other recommended way to approach a use case like this?
The text was updated successfully, but these errors were encountered: