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

npm run build does not produce the webpack file cache #1995

Closed
2 of 4 tasks
hkjeffchan opened this issue Mar 21, 2023 · 4 comments
Closed
2 of 4 tasks

npm run build does not produce the webpack file cache #1995

hkjeffchan opened this issue Mar 21, 2023 · 4 comments

Comments

@hkjeffchan
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

webpack/webpack#12345

compiler.close() should be called somewhere.
I tried to fix it by calling compiler.close() in lib/compiler/webpack-compiler.ts but it does now work

Minimum reproduction code

https://github.com/hkjeffchan/nestjsCliWebpackCacheDemo

Steps to reproduce

  1. npm run build does not produce the webpack file cache
  2. npm run start:dev does produce the webpack file cache

Expected behavior

npm run build should produce the webpack file cache

Package version

9.3.0

NestJS version

9.3.11

Node.js version

18.15.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@hkjeffchan
Copy link
Author

I tried to modify lib/compiler/webpack-compiler.ts and add this before compiler.run(afterCallback);

            compiler.hooks.shutdown.tap('shutdown', () => {
              console.log('shutdown');
              compiler.close(); 
            });

This does not work as this is not called.

            compiler.hooks.done.tap('done', () => {
              console.log('done');
              compiler.close(); 
            });

This does create the cache directory and it said "webpack 5.76.2 compiled successfully" but i got the following errors:

/Applications/MAMP/htdocs/nest-playground/node_modules/webpack/lib/HookWebpackError.js:68
                callback(null, result);
                ^

TypeError: callback is not a function
    at /Applications/MAMP/htdocs/nest-playground/node_modules/webpack/lib/HookWebpackError.js:68:3
    at _done (eval at create (/Applications/MAMP/htdocs/nest-playground/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at eval (eval at create (/Applications/MAMP/htdocs/nest-playground/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:34:22)

@hkjeffchan
Copy link
Author

I fixed it... a callback function is required for compiler.close()

created a PR for this

@hkjeffchan
Copy link
Author

#1997

@kamilmysliwiec
Copy link
Member

Let's track this here #1997

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants