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

PostCSS plugin breaks bundling of SSR CSS-based import attributes #1355

Closed
thescientist13 opened this issue Dec 21, 2024 · 0 comments · Fixed by #1361
Closed

PostCSS plugin breaks bundling of SSR CSS-based import attributes #1355

thescientist13 opened this issue Dec 21, 2024 · 0 comments · Fixed by #1361
Assignees
Labels
alpha.2 bug Something isn't working Plugins Greenwood Plugins question Further information is requested SSR v0.31.0
Milestone

Comments

@thescientist13
Copy link
Member

Type of Change

Bug

Summary

Based on observations in this project it looks like if you are using CSS based Import Attributes and SSR / custom resource loaders, PostCSS is trying to bundle JavaScript based resources and throwing an error

Error [RollupError]: Expression expected
    at getRollupError (file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/rollup@4.28.1/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
    at convertProgram (file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/rollup@4.28.1/node_modules/rollup/dist/es/shared/parseAst.js:1084:26)
    at Object.parseAst [as parse] (file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/rollup@4.28.1/node_modules/rollup/dist/es/shared/parseAst.js:2069:87)
    at Object.transform (file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/@greenwood+cli@0.31.0-alpha.1/node_modules/@greenwood/cli/src/config/rollup.config.js:290:24)
    at async transform (file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/rollup@4.28.1/node_modules/rollup/dist/es/shared/node-entry.js:19663:16)
    at async ModuleLoader.addModuleSource (file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/rollup@4.28.1/node_modules/rollup/dist/es/shared/node-entry.js:19879:36) {
  code: 'PLUGIN_ERROR',
  pos: 627,
  pluginCode: 'PARSE_ERROR',
  plugin: 'greenwood-import-meta-url',
  hook: 'transform',
  id: '/Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]__@spectrum-css+_ice4y2gdhp2yq7ivdbp3yo6byi/node_modules/@spectrum-css/card/dist/index.css'
}

Details

I think the issue can be reproduced by having an SSR route that uses (a component) with an import attribute and using prerender with custom resource loaders, e.g.

// src/pages/index.js
import sheet from '../styles/theme.css' with { type: 'css' };

I notice that we don't have any tests for this use case for the PostCSS loader
https://github.com/ProjectEvergreen/greenwood/tree/v0.30.2/packages/plugin-postcss/test/cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha.2 bug Something isn't working Plugins Greenwood Plugins question Further information is requested SSR v0.31.0
Projects
1 participant