-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
fix(terser): always make at least 1 worker thread #1604
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const os = require('os'); | ||
|
||
const test = require('ava'); | ||
const { rollup } = require('rollup'); | ||
|
||
|
@@ -356,3 +358,21 @@ test.serial('terser preserve vars in nameCache when provided', async (t) => { | |
} | ||
}); | ||
}); | ||
|
||
test.serial('minify when os.cpus().length === 0', async (t) => { | ||
const original = os.cpus; | ||
os.cpus = () => []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe overwriting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @easrng could you please take a look? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @easrng should this also include |
||
try { | ||
const bundle = await rollup({ | ||
input: 'test/fixtures/unminified.js', | ||
plugins: [terser()] | ||
}); | ||
const result = await bundle.generate({ format: 'cjs' }); | ||
t.is(result.output.length, 1); | ||
const [output] = result.output; | ||
t.is(output.code, '"use strict";window.a=5,window.a<3&&console.log(4);\n'); | ||
t.falsy(output.map); | ||
} finally { | ||
os.cpus = original; | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the test needs to also make
os.availableParallelism
unavailable, otherwise it won't useos.cpus
.