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

feat(npm/webpack-preprocessor): WIP support webpack 5 alongside webpack 4 #16493

Merged
merged 3 commits into from
May 13, 2021
Merged
Changes from all commits
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
12 changes: 7 additions & 5 deletions npm/webpack-preprocessor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F
// when we should watch, we hook into the 'compile' hook so we know when
// to rerun the tests
if (file.shouldWatch) {
debug('watching')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol what's wrong with this debug message?


if (compiler.hooks) {
// TODO compile.tap takes "string | Tap"
// so seems we just need to pass plugin.name
Expand All @@ -352,7 +350,9 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F

if (file.shouldWatch) {
// in this case the bundler is webpack.Compiler.Watching
(bundler as webpack.Compiler.Watching).close(cb)
if (bundler && 'close' in bundler) {
bundler.close(cb)
lmiller1990 marked this conversation as resolved.
Show resolved Hide resolved
}
}
})

Expand Down Expand Up @@ -380,8 +380,10 @@ preprocessor.__reset = () => {
bundles = {}
}

function cleanseError (err: string) {
return err.replace(/\n\s*at.*/g, '').replace(/From previous event:\n?/g, '')
function cleanseError (err: string | Error) {
let msg = typeof err === 'string' ? err : err.message

return msg.replace(/\n\s*at.*/g, '').replace(/From previous event:\n?/g, '')
}

export = preprocessor