Closed liby closed 2 years ago
It sounds like you need to enable the Babel importAssertions
option:
withStyle9({
parserOptions: {
plugins: ['typescript', 'jsx', 'importAssertions'],
},
})
If the issue remains please add a repo with a reproduction
It sounds like you need to enable the Babel
importAssertions
option:withStyle9({ parserOptions: { plugins: ['typescript', 'jsx', 'importAssertions'], }, })
If the issue remains please add a repo with a reproduction
Thank you. I tested it for a few days and it worked for me. But after adding the pages/_document
, I encountered the problem described by #54. Maybe you have any good ideas?
Reproduce:
Create Next.js project
Install style9, next-transpile-modules, next-contentlayer
Update next.config.js
const { withContentlayer } = require("next-contentlayer");
const withTM = require("next-transpile-modules")(["style9"]);
const withStyle9 = require("style9/next");
function compose(...plugins) {
return (options) => {
return plugins.reduce((acc, next) => {
return next(acc);
}, options);
};
}
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
};
module.exports = withStyle9({
parserOptions: {
plugins: ["typescript", "jsx", "importAssertions"],
},
})(compose(withContentlayer, withTM)(nextConfig));
Update index file to use style9
Create pages/_document
uses style9
Add new style attributes and refresh - Fails
style9/next does not seem to work nice with next-contentlayer. When the two plugins are used together, an error is thrown:
Syntax error: Support for the experimental syntax 'importAssertions' isn't currently enabled (3:43):
```js // next.config.js const { withContentlayer } = require("next-contentlayer"); const withTM = require("next-transpile-modules")(["style9"]); const withStyle9 = require("style9/next"); const nextConfig = withContentlayer({ ...withStyle9()(withTM()), }); module.exports = nextConfig; # or module.exports = withTM(withStyle9({})(withContentlayer({}))); # or module.exports = { ...withContentlayer(), ...withStyle9()(withTM()), }; # or function compose(...plugins) { return (options) => { return plugins.reduce((acc, next) => { return next(acc); }, options); }; } module.exports = compose( withContentlayer, withStyle9(), withTM )() # or module.exports = withStyle9()(compose( withContentlayer, withTM )()) ```I have tried many solutions, all to no avail.