-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
NCC fails to run on the first time, but succeeds on the second run. #208
Comments
package
The example has been simplified further. Steps are now: |
Please note the new example shows that this is not a Monorepo issue. Simply a project with directories issue... |
I wonder if it's related to our new caching feature. |
So the original error is the valid error in the following case:
"io-ts" can't be resolved from "shared/foo.ts" so there is an error thrown. The fact that it works the second time is due to the cache exactly storing the resolution somehow, which sounds like a Webpack 5 bug here to me as the cache shouldn't be using the stored resolution for "io-ts" where it was a known failure. These sorts of bugs are to be expected I suppose with caching work - error caching is very much a standard edge case. //cc @sokra Note the fix of the error is to move the node_modules down out of app1 so that it is shared for both, or to ensure a node_modules exists in shared with the correct dependency. |
Please note the error also exists when there is just one package.json in root |
@mattapperson on that commit I'm getting the build working fine with and without caching. |
@johnnyreilly this seem to be related to the way ts-loader reports errors/warnings to webpack. They are not attached to the Module, but to the Compilation instead. For caching errors must be attached to the Modules, best using Maybe it makes more sense to run ts-loader in transpile-only mode and run the typechecking separately? |
Hey @sokra
Is this a change in behaviour with webpack 5? I believe ts-loader has always used a combination of the https://github.com/TypeStrong/ts-loader/search?q=errors.push&unscoped_q=errors.push i.e. either Could you point me to an example that illustrates how to use
That's generally my advice when using |
This is not new. As I understand ts-loader it attaches a This works fine as long ts-loader was executed at least once. Without persistent caching this is always true when a typescript file is in the project. With persistent caching it can (and will) happen that no typescript file was changed since last run and all typescript modules can be restored from cache. In this case ts-loader is not executed (it's not even Errors pushed to Errors pushed to There are multiple options to solve this: Always add errors/warnings to a module and avoid Always add the plugin that add the errors to the compilation. This means it would be required to add a |
Thanks for responding @sokra .
Exactly right.
Cool - I wasn't aware of that API.
So it's safe to do this:
If using this approach is the |
This was resolved in #210. |
Greetings!
I have searched for issues related to the one me and @mattapperson are facing, but I have failed to find it. Please advise if this is a known issue.
Summary
Monorepo available here. We can successfully run it locally, but building with
cd app1 && ncc build index.ts
fails when executed for the first time. However, executing it again succeeds!Step By Step
Any clues?
The text was updated successfully, but these errors were encountered: