johanholmerin / style9

CSS-in-JS compiler inspired by Meta's stylex
MIT License
570 stars 27 forks source link

First attempt to support Next.js 13 appDir #83

Closed SukkaW closed 1 year ago

SukkaW commented 1 year ago

cc @TxHawks @Dwlad90

Would you like to try the patch to see if it works?

Note the appDir might still not work, but the current pages is not affected (the behavior is retained, thus it is fully backward compatible).

See also:

SukkaW commented 1 year ago

After digging a little into Next.js and webpack-virtual-modules, it turns out that Next.js just doesn't work well with webpack-virtual-modules. And that's why it doesn't work on Next.js 13 appDir.

I have started another project style9-webpack, re-implements style9's webpack plugin without using webpack-virtual-modules.

@TxHawks @Dwlad90 would you like to give style9-webpack a shot?

@johanholmerin I am really willing to port my style9-webpack implementation back to style9, but:

johanholmerin commented 1 year ago

If your new plugin works better I'd be happy to integrate it. As for the inline loaders, it consists of the name of the loader, followed by an question mark and options, an exclamation mark, and then the normal path, e.g. loader-name?{options}!./file.css. Here's the best documentation I could find on it: https://webpack.js.org/concepts/loaders/#inline

SukkaW commented 1 year ago

If your new plugin works better I'd be happy to integrate it.

It does work for me.

As for the inline loaders, it consists of the name of the loader, followed by an question mark and options, an exclamation mark, and then the normal path, e.g. loader-name?{options}!./file.css. Here's the best documentation I could find on it: https://webpack.js.org/concepts/loaders/#inline

https://github.com/SukkaW/style9-webpack/blob/a069a46b14dcf3f8c4e20cf04ca851584199b6e8/src/loader.ts#L69-L74

image

Because I am not familiar with inline loader syntax, I don't know where to put inlineLoader (where css-loader and MiniExtractPlugin.loader would be). Is it right after !=! or is it after virtualResourceLoader?

SukkaW commented 1 year ago

I am closing this PR now, because:

I will continue doing some experiments in my style9-webpack repo, and then I will open other PRs to backport some of the features/optimizations.