Skip to content

preloaders versus postloaders #1

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

Closed
texastoland opened this issue May 26, 2016 · 10 comments
Closed

preloaders versus postloaders #1

texastoland opened this issue May 26, 2016 · 10 comments
Assignees
Labels

Comments

@texastoland
Copy link

Getting ready to try this out and wondered why you recommend preloaders instead of postloaders? Should I not run it after PostCSS? I suppose it wouldn't get picked up by TypeScript then? Does that mean I should compile all my CSS in preloaders?

@olegstepura
Copy link
Owner

olegstepura commented May 26, 2016

Hi! I recommended to use it in preloaders since typed-css-modules generates typescript files needed in loaders phase to typescript itself.

@texastoland
Copy link
Author

Hmm I guess there's no way to pipe through additional loaders just once since TypeScript doesn't use WebPack's require?

@olegstepura
Copy link
Owner

I'm not typescript compiler expert. I know that typescript itself uses moduleResolution option in tsconfig.json to control one of the two possible build-in loader behaviors. But with webpack we use typescript-loader and you may wish to ask same question there (they should know for sure whether it's possible to inject webpack's loader to typescript or not).

@olegstepura olegstepura self-assigned this May 26, 2016
@olegstepura
Copy link
Owner

@AppShipIt is your question answered? Did you get any more info from typescript experts?

@texastoland
Copy link
Author

The root issue is TypeScript doesn't use WebPack to look up modules so this must be run in preloaders (like you recommended). But I don't think it'll work with cssnext without chaining after other PostCSS plugins. That would mean nothing else could run before PostCSS. Stylelint is available as a plugin (order doesn't matter) so perhaps it's not an issue. Since typed-css-modules uses PostCSS css-modules-core maybe my use case would be better served as a PostCSS plugin. Feel free to close I'll try again later!

@mohsen1
Copy link
Contributor

mohsen1 commented Jun 25, 2016

I'm trying to use this loader in my preLoaders but I'm still getting module not found error:

 webpack                                                                1662ms  Sat Jun 25 11:06:27 2016
ts-loader: Using typescript@1.8.10 and /Users/mazimi/Projects/rah-foundation/website/tsconfig.json
Hash: 840e83034d9d41d62337
Version: webpack 1.13.1
Time: 1857ms
    Asset    Size  Chunks             Chunk Names
client.js  879 kB       0  [emitted]  client
    + 236 hidden modules

ERROR in ./components/FAQ/style.css
Module build failed: Error: Could not find file: '/Users/mazimi/Projects/rah-foundation/website/components/FAQ/style.css'.
    at getValidSourceFile (/Users/mazimi/Projects/rah-foundation/website/node_modules/typescript/lib/typescript.js:48860:23)
    at Object.getEmitOutput (/Users/mazimi/Projects/rah-foundation/website/node_modules/typescript/lib/typescript.js:51922:30)
    at Object.loader (/Users/mazimi/Projects/rah-foundation/website/node_modules/ts-loader/index.js:432:34)
 @ ./components/FAQ/index.tsx 8:12-34

Here is my webpack config:
https://github.com/rah-foundation/website/blob/75c4be4cacbfe94c6a1f850d30370e9135354152/webpack.config.ts

Any idea why I'm getting this error?

@olegstepura
Copy link
Owner

Hi, @mohsen1
I experience the same issue from time to time. Currently I don't know how to solve it. You can take a look at discussion here for more details.

@mitermayer
Copy link

I will try this loader out, If i hit the above error I will try to fix it and submit a PR

@mohsen1
Copy link
Contributor

mohsen1 commented Oct 28, 2016

I believe my PR #8 fixed this issue.

@olegstepura
Copy link
Owner

Hi, guys! FYI: I merged #8 and released v0.0.6 just now.
Not sure if I can close this issue.

tgroutars referenced this issue in producthunt/typed-css-modules-loader May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants