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

Synchronously create files #8

Closed
athyuttamre opened this issue Jun 26, 2016 · 7 comments
Closed

Synchronously create files #8

athyuttamre opened this issue Jun 26, 2016 · 7 comments

Comments

@athyuttamre
Copy link

Is there a way to synchronously create the .d.ts files? I'm using this module with webpack and need to generate these files before I run the TypeScript compiler.

@athyuttamre
Copy link
Author

Hmm, never mind, even synchronously creating files doesn't seem to be fixing my issue (I hardcoded the output and tried it out.) Would be nice to have the option though!

@AlexGalays
Copy link

AlexGalays commented Jul 17, 2016

That is indeed surprising.

The example invokes typed-css-modules immediately followed by tsc. That will often fail due to missing or outdated d.ts files, won't it ?

@athyuttamre
Copy link
Author

@AlexGalays that's correct. What's happening is:

  • Webpack reads the filesystem, and makes an in memory cache of the changed files.
  • typed-css-modules-loader uses this cache and generates the .d.ts files.
  • tsc uses this cache and compiles the TypeScript files. At this point the new .d.ts files are not in the cache, so tsc doesn't recognize them and throws errors.

The next time webpack runs, it reads the filesystem again, and this time the .d.ts files are included. This way tsc compiles correctly without errors.

For more discussion, see this issue: #2.

Closing for now because synchronous creation isn't that useful unless we can update the webpack cache before tsc uses it.

@AlexGalays
Copy link

AlexGalays commented Jul 19, 2016

@athyuttamre Thanks for the loader lead.
Will try it when I have some time.

@AlexGalays
Copy link

is there no way to create the .d.ts files around the same time the JS bundle is rewritten ? As it stands, my app is recompiled twice for every change so I reverted to untyped css modules for now.

@athyuttamre
Copy link
Author

That's our experience too. There is an emitFile API in the Webpack loader docs, but I never got it to work. Perhaps someone with more experience could look into it.

@AlexGalays
Copy link

AlexGalays commented Feb 8, 2017

@Quramy Is this fixed by any chance? css modules are the last untyped bit in our whole app.

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

No branches or pull requests

2 participants