johanholmerin / style9

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

Upgrade nextjs example dependencies #37

Closed dpeek closed 3 years ago

dpeek commented 3 years ago

Upgrades next, react and next-transpile-modules dependencies in example/nextjs to latest.

Adds css-loader as a library dependency – not sure why this only errors after the upgrade, but as it is a dependency of the webpack loader I suppose it should be? Either that or it could be a peerDependency... happy to update if needed.

dpeek commented 3 years ago

Alternately you could switch to multiple npm packages with css-loader dependency in @style9/next or something...

johanholmerin commented 3 years ago

Next.js started bundling css-loader in version 10. Instead of using a different version, we should probably try to resolve next/dist/compiled/css-loader, and if it doesn't exist, go back to css-loader.

Otherwise looks good.

dpeek commented 3 years ago

I don't think css-loader is required directly by style9, only referenced as a string in the next plugin... seems weird that it wouldn't find the next version already?

Could you explain how I would try to resolve the next version?

johanholmerin commented 3 years ago

I was thinking something like this:

const cssLoader = (() => {
  try {
    // v10+
    return require.resolve('next/dist/compiled/css-loader')
  } catch (_) {
    return 'css-loader';
  }
})();
// ...
const outputLoaders = [{ loader: cssLoader }];
johanholmerin commented 3 years ago

Fixed in 0.10.3

dpeek commented 3 years ago

Many thanks :)