Migrating from 0.x
This page lists every breaking change from 0.12.x to 1.0. Work through it top to bottom.
Requirements
- [ ] Solid 2.0. The peer range is now
solid-js@^2.0.0-rc.5and@solidjs/web@^2.0.0-rc.5. Upgrade Solid first, then installsolid-styled@nextandunplugin-solid-styled@next. - [ ] Node. Both packages now require Node
^20.19.0 || >=22.12.0, the rangeoxc-parserandunpluginneed. Upgrade Node if you are on an older release. - [ ] Vite 8.
unplugin-solid-stylednow requiresvite@>=8when you use Vite. Upgrade Vite. - [ ] ESM only. Both packages ship ES modules only. The CommonJS builds and the
developmentexport condition are gone. Node^20.19.0 || >=22.12.0canrequire()them, so most setups need no change. In a CommonJS config, the plugin is ondefault:require('unplugin-solid-styled').default.vite().
Plugins
-
[ ]
vite-plugin-solid-styledandrollup-plugin-solid-styledare removed. Uninstall them and installunplugin-solid-styled. Replace the default export call with the matching entry. The options are the same.// Before import solidStyled from 'vite-plugin-solid-styled'; solidStyled({ prefix: 'my-app' }); // After import solidStyled from 'unplugin-solid-styled'; solidStyled.vite({ prefix: 'my-app' });For Rollup, use
solidStyled.rollup(options). See Getting started. -
[ ] The
envoption is removed. The 1.0 compiler never read it. Deleteenvfrom your plugin options andcompile()calls. TypeScript reports it as an unknown property.
Compiler API
Skip this section if you only use the bundler plugin.
- [ ]
compile()is synchronous.compile(id, code, options)fromsolid-styled/compilernow returns{ code, map }directly instead of a promise. Remove theawait. - [ ] The source map comes from magic-string.
mapis a magic-string source map withhires: true, not a Babel map. It has the standardversion,sources,namesandmappingsfields. - [ ] Errors are
CompileError. A parse error, a CSS error in a template or an invalidstylevalue throws aCompileError. 0.x threw a Babel error. It has 1-basedlineandcolumnfields, and the message ends with(line:column). Update any code that reads Babel error fields such asloc. - [ ] Babel is gone.
@babel/core,@babel/traverseand@babel/typesare no longer dependencies. Add them to your ownpackage.jsonif your code imported them through solid-styled.
Runtime
- [ ]
StyleRegistryhas a default context. Solid 2.0 throws when a context without a default is read without a provider.useSolidStyledkeeps working outside a registry. No action needed. - [ ]
<StyleRegistry auto>usesuseHead. Solid 2.0 removeduseAssets, so the sheets are now added as head tags throughuseHead. No action needed, unless your server template placed theuseAssetsoutput itself. Then render the head tags that Solid 2.0 collects. - [ ] JSX types moved to
@solidjs/web. Thejsx,globalanduse:solid-styledattribute types now augment theJSXnamespace of@solidjs/web. That is where Solid 2.0 exposes it. Keep/// <reference types="solid-styled" />orcompilerOptions.types. See TypeScript.
Output
- [ ] The scope hash ignores query strings. The hash comes from the file path without its query. A module compiled with and without a query suffix shares one scope. Some scope ids differ from 0.x. Rebuild the server and client together, and do not hard-code scope ids in tests or selectors.
- [ ] One import for runtime helpers. The compiled code imports every helper in one statement, with
_namelocals such as_useSolidStyled. Update any tooling or snapshot test that matches the old output. - [ ] Units after an interpolation use
calc().width: ${size()}pxnow compiles towidth: calc(var(--s-v-...) * 1px). 0.x compiled it tovar(--s-v-...) px, which browsers drop. Pass a bare number when a unit follows the interpolation. If you added the unit inside the value, such as${size() + 'px'}, that still works. - [ ] Spread attributes merge styles. With 0.12.1 the CSS variables replaced the
stylefrom a spread such as{...props}. Now the CSS variables merge into whicheverstyleSolid resolves. Remove any workaround that mergedprops.styleby hand. See Spread attributes. - [ ] Constructor parameter properties shadow
css. A parameter property such asconstructor(private css: any)now shadows thecssimport, like any other local binding. 0.12.1 compiledcsstemplates in that constructor anyway. Rename the parameter if a template there should compile.