-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat(css)!: remove css default export #14125
feat(css)!: remove css default export #14125
Conversation
Run & review this pull request in StackBlitz Codeflow. |
f761c26
to
ded43c9
Compare
b4daf02
to
8698140
Compare
/ecosystem-ci run |
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Ok with non-squashing this one 👍
I'll run the ecosystem ci as the previous run was before the main branch was merged. |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
qwik is the only failure that isn't failing in main branch. |
Leave a way here to restore the legacy behavior of previous version, anyways, someone might need it. // works for versions before vite5
import { type PluginOption, preprocessCSS, type ResolvedConfig } from 'vite';
export function createCssModulePlugin(): PluginOption {
let resolvedConfig: ResolvedConfig;
let moduleCache: Map<string, Record<string, string>>;
return [
{
name: 'plugin:force-css-module',
enforce: 'post',
configResolved(config) {
resolvedConfig = config;
},
buildStart() {
// Ensure a new cache for every build (i.e. rebuilding in watch mode)
moduleCache = new Map();
},
async transform(code, id) {
if (/(?<!global|module)\.scss(?!\?inline)$/.test(id)) {
const { modules, code: css } = await preprocessCSS(code, id + '.module.scss', resolvedConfig);
moduleCache.set(id, modules);
return css;
}
},
},
{
name: 'plugin:force-css-module-post',
enforce: 'post',
async transform(_, id) {
const moduleCode = moduleCache.get(id);
if (moduleCode) {
return {
code: `export default JSON.parse(${JSON.stringify(moduleCode)})`,
map: { mappings: '' },
moduleSideEffects: 'no-treeshake',
};
}
},
},
];
} |
Description
Removes CSS default export and deprecation warnings.
Also removes the
?used
hack.refs #11094 #11121 #8278
fixes #12001 (indirectly)
fixes #13885 (indirectly)
Additional context
I recommend merging this PR without squashing as I believe it's better for debugging later.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).