Skip to content
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

refactor: rewrite tests to use webpack compiler, drop node 8 #360

Merged
merged 25 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle target array
  • Loading branch information
beeequeue committed Mar 5, 2021
commit 7e96c08c6cded7fbb7f83d3d769f1b23730a2294
29 changes: 16 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,22 @@ class Dotenv {
return formatted
}

shouldStub ({ target, version }) {
return (
// If we're on Webpack 5
version.startsWith('5') &&
// And we're not configured to not stub
this.config.ignoreStub !== true &&
// And
(
// We are configured to always stub
this.config.ignoreStub === false ||
// Or if we should according to the target
(!target.includes('node') && !isMainThreadElectron(target))
)
shouldStub ({ target: targetInput, version }) {
const targets = Array.isArray(targetInput) ? targetInput : [targetInput]

return targets.every(
target =>
// If we're on Webpack 5
version.startsWith('5') &&
// And we're not configured to not stub
this.config.ignoreStub !== true &&
// And
(
// We are configured to always stub
this.config.ignoreStub === false ||
// Or if we should according to the target
(!target.includes('node') && !isMainThreadElectron(target))
)
)
}

Expand Down
6 changes: 5 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,19 @@ describe.each(versions)('%s', (_, DotenvPlugin) => {
const plugin = new DotenvPlugin({ path: envSimple })
const cases = [
['web', true],
[['web'], true],
['es5', true],
['es2020', true],
[['es2020', 'web'], true],
['electron-renderer', true],
['electron9-renderer', true],
['electron-preload', true],
['node', false],
[['node'], false],
['node14', false],
['electron-main', false],
['electron9-main', false]
['electron9-main', false],
[['es2020', 'node'], false]
]

test.each(cases)('%s', (target, shouldStub, done) => {
Expand Down