@teacss/rsbuild 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ tool.
|
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
import { defineConfig } from "@rsbuild/core";
|
|
20
|
-
import { pluginTeacss } from "teacss/rsbuild";
|
|
20
|
+
import { pluginTeacss } from "@teacss/rsbuild";
|
|
21
21
|
|
|
22
22
|
export default defineConfig({
|
|
23
23
|
plugins: [pluginTeacss()],
|
|
@@ -33,6 +33,8 @@ export default defineConfig({
|
|
|
33
33
|
Positive `@source` globs register their stable base directories as Rsbuild
|
|
34
34
|
context dependencies. New files matching an include therefore trigger a
|
|
35
35
|
rebuild; negative source patterns are not registered as watch roots.
|
|
36
|
+
Default source discovery skips dependency and common build-output directories,
|
|
37
|
+
while explicit `@source` globs can include them.
|
|
36
38
|
When directive transforms are enabled, their default CSS matcher is combined
|
|
37
39
|
with a custom entry `test`, so configured non-`.css` entries such as `.pcss`
|
|
38
40
|
still reach TeaCSS.
|
|
@@ -42,6 +44,5 @@ exported for integration tests and advanced tooling.
|
|
|
42
44
|
|
|
43
45
|
## Status
|
|
44
46
|
|
|
45
|
-
Pre-1.0.
|
|
46
|
-
`teacss
|
|
47
|
-
`@teacss/rsbuild` directly when they intentionally do not use the facade.
|
|
47
|
+
Pre-1.0. `@teacss/rsbuild` is the owning Rsbuild adapter. Applications install
|
|
48
|
+
it beside the `teacss` runtime and import it directly from `@teacss/rsbuild`.
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ interface TeacssPluginOptions extends TeacssGenerateOptions {
|
|
|
30
30
|
test?: RegExp;
|
|
31
31
|
/**
|
|
32
32
|
* Inline `@apply` (plus `@screen` / `theme()` / `icon()`) in `.css` files —
|
|
33
|
-
* `@apply p:4
|
|
33
|
+
* `@apply p:4 rd:2x;` inside a rule becomes the resolved declarations,
|
|
34
34
|
* conditioned tokens (`@apply p:4@hover`) become host-scoped rules. A lexical
|
|
35
35
|
* guard skips config and transformer setup for ordinary CSS. `false` disables
|
|
36
36
|
* it; `{ test }` narrows the scope (default: all CSS).
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import{statSync as t}from"node:fs";import{dirname as n,isAbsolute as r,resolve as i}from"node:path";import a from"node:process";import{DEFAULT_SOURCE_IGNORE as o,generateSources as s,readSourceFile as c}from"@teacss/runtime/source-generation";const l=/\.(css|postcss|sass|scss|less|stylus|styl)(\?|$)/,u=(e,t=0)=>e<<16|t<<8,d={safari:u(14),chrome:u(90),firefox:u(88),edge:u(90)};function f(e,t){e.lastIndex=0;let n=e.test(t);return e.lastIndex=0,n}function p(e){return e.includes(`@apply`)||e.includes(`--at-apply`)||e.includes(`@screen`)||e.includes(`theme(`)||e.includes(`icon(`)}function m(e,n,r,i){let a=t(e,{throwIfNoEntry:!1});a?a.isDirectory()?i(e):n(e):r(e)}const h=/[*?[\]{}()]/;function
|
|
1
|
+
import{createRequire as e}from"node:module";import{statSync as t}from"node:fs";import{dirname as n,isAbsolute as r,resolve as i}from"node:path";import a from"node:process";import{DEFAULT_SOURCE_IGNORE as o,generateSources as s,readSourceFile as c}from"@teacss/runtime/source-generation";const l=/\.(css|postcss|sass|scss|less|stylus|styl)(\?|$)/,u=(e,t=0)=>e<<16|t<<8,d={safari:u(14),chrome:u(90),firefox:u(88),edge:u(90)};function f(e,t){e.lastIndex=0;let n=e.test(t);return e.lastIndex=0,n}function p(e){return e.includes(`@apply`)||e.includes(`--at-apply`)||e.includes(`@screen`)||e.includes(`theme(`)||e.includes(`icon(`)}function m(e,n,r,i){let a=t(e,{throwIfNoEntry:!1});a?a.isDirectory()?i(e):n(e):r(e)}const h=/[*?[\]{}()]/;function g(e,t){let r=t;for(;h.test(r);)r=n(r);return i(e,r)}async function _(e,t,n){let{glob:r}=await import(`tinyglobby`),i=await r(t,{cwd:e,absolute:!0,ignore:n});return{files:i,sources:i.map(c)}}async function v(e={}){let[{defaultFilesystemGlobs:t},n]=await Promise.all([import(`@teacss/runtime`),A(e)]);return y(e,n.generator,t,n.sources)}async function y(e,t,r,i=[]){let{cwd:c=a.cwd(),contents:l}=e,u=r??(await import(`@teacss/runtime`)).defaultFilesystemGlobs,d=i[0]?n(i[0]):c,f=t.config.content?.filesystem,p=f??u,m=e.ignore??(f===void 0?o:[]),{files:h,sources:g}=l?{files:[],sources:l}:await _(d,p,m),v=await s(t,h,g);return{css:v.getLayers()||``,utilities:v.matched.size,files:h}}function b(e,t=[]){return async(n,r)=>{let{glob:i}=await import(`tinyglobby`),a=await i(n,{cwd:e,absolute:!0,ignore:[...r,...t]});return{files:a,sources:await Promise.all(a.map(c))}}}const x={articles:`@teacss/preset-articles`,icons:`@teacss/preset-icons`,standard:`@teacss/preset-standard`};function S(t,n){try{return n.resolve(t)}catch(r){let i;try{i=n.resolve(`teacss/package.json`)}catch{throw r}return e(i).resolve(t)}}function ee(e){return e.filter(e=>!e.startsWith(`.`)&&!r(e))}function te(t,n){let r=e(i(n,`_`));return t.map(e=>{let t=Object.hasOwn(x,e)?x[e]:void 0;return t?S(t,r):r.resolve(e)})}function ne(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}async function C(e,t){return w(e,t,await j(e,t.base))}async function w(e,t,n){let[{parseEntry:r},{spliceEntry:i}]=await Promise.all([import(`@teacss/config`),import(`@teacss/directives`)]),a=r(e),o=a.sources.filter(e=>!e.exclude).map(e=>e.glob),c=a.sources.filter(e=>e.exclude).map(e=>e.glob),{files:l,sources:u}=t.contents?{files:[],sources:t.contents}:t.readSources?await t.readSources(o,c):{files:[],sources:[]},d=await s(n.generator,l,u);return{css:i(e,d.getLayers()||``),files:l,matched:d.matched.size,unknown:n.unknown,hasPreset:n.hasPreset}}async function T(e,{minify:t=!0,targets:n,browserslist:r}={}){let{transform:i,browserslistToTargets:a}=await import(`lightningcss`),o=n??(r?.length?a(r):d),s=D(e),c=i({filename:`teacss.css`,code:Buffer.from(s.css),minify:t,errorRecovery:!0,targets:o});return{css:s.restore(c.code.toString()),skipped:c.warnings?.length??0}}const E=/(^|[;{])((?:\s|\/\*[\s\S]*?\*\/)*)all((?:\s|\/\*[\s\S]*?\*\/)*):((?:\s|\/\*[\s\S]*?\*\/)*)(?=(?:var|env)\()/gi;function D(e){let t=`--teacss-optimized-all`;for(;e.includes(t);)t+=`-x`;return{css:e.replace(E,(e,n,r,i,a)=>`${n}${r}${t}${i}:${a}`),restore:e=>e.replaceAll(t,`all`)}}function O(e,t){return typeof e==`boolean`||e==null?(e??!0)&&t:e.css!==!1&&(e.css===`always`||t)}async function k(e){return(await A(e)).generator}async function A(e,t){let{cwd:n=a.cwd(),configPath:r,config:i}=e,{createGenerator:o}=await import(`@teacss/core`),s=t??(await import(`@teacss/config`)).createRecoveryConfigLoader(),c=i?{config:i,sources:[]}:await s(n,r);return{generator:await o(c.config),sources:c.sources}}async function j(e,t){let[{resolveEntryConfig:n},{createGenerator:r}]=await Promise.all([import(`@teacss/config`),import(`@teacss/core`)]),{config:i,sources:a,unknown:o}=await n(e,t);return{generator:await r(i),sources:a,unknown:o,hasPreset:!!i.presets?.length}}async function M(e,t,n){let[{transformDirectives:r},{default:i}]=await Promise.all([import(`@teacss/directives`),import(`magic-string`)]),a=new i(e);return await r(a,n,{},t),a.toString()}async function N(e,t={},n){return p(e)?M(e,n,await k(t)):e}function P(e={}){let{optimize:r,targets:o,test:s=/index\.css$/,apply:c,...u}=e,d=c!==!1,h=typeof c==`object`&&c.test||l;return{name:`teacss`,setup(e){let c,_=()=>c??=import(`@teacss/config`).then(({createRecoveryConfigLoader:e})=>e()),v=new Map,x=new Map,S=new Map,C=e=>{let t=v.get(e);if(t)return t;let n=_().then(e=>A(u,e));return v.set(e,n),n};e.onBeforeEnvironmentCompile(({environment:e})=>{v.delete(e.name),x.delete(e.name)}),e.transform({test:d?[l,s]:s},async({code:c,environment:l,addDependency:_,addMissingDependency:E,addContextDependency:D,resourcePath:k})=>{let A=k||``,N=f(s,A),P=d&&p(c),F=P&&f(h,A);if(!N&&!F)return c;let{parseEntry:re}=await import(`@teacss/config`),I=N?re(c):void 0,L=I?.hasTeacss===!0;if(!L&&!F)return c;let R=!!(I&&(I.presets.length>0||I.sources.length>0||I.custom.length>0)),z=n(k||`${u.cwd??a.cwd()}/index.css`),B=k||i(z,`index.css`);for(let e of I?.sources??[])e.exclude||m(g(z,e.glob),_,E,D);let V=ee(I?.presets??[]),H,U,W;L&&(R?(H=j(c,z).then(e=>(U={...e,sources:Array.from(new Set([B,...e.sources]))},U)).catch(async t=>{let{getConfigSourcesFromError:n}=await import(`@teacss/config`),r=n(t);for(let e of r)m(e,_,E,D);let i=S.get(l.name);if(!i||i.id!==B)throw t;let a=Array.from(new Set([...i.state.sources,...r]));return e.logger.warn(`@teacss/rsbuild: keeping the last valid config for ${B} while its preset graph is invalid`),a.length===i.state.sources.length?i.state:{...i.state,sources:a}}),x.set(l.name,H),d?v.set(l.name,H):v.delete(l.name)):(v.delete(l.name),x.delete(l.name),S.delete(l.name)));let G=()=>{U&&W&&H&&x.get(l.name)===H&&S.set(l.name,{id:B,packagePresetDependencies:W,packagePresetSpecifiers:V,state:U})},K=c,q;if(P&&(L||F)){try{q=await C(l.name)}catch(e){if(!H){let{getConfigSourcesFromError:t}=await import(`@teacss/config`);for(let n of t(e))m(n,_,E,D)}throw e}for(let e of q.sources)m(e,_,E,D);K=await M(c,A,q.generator)}if(!L)return K===c?c:{code:K};let J,Y,X,Z=[],Q=!0,$=[];if(R){let n=H?await H:await j(K,z);({css:J,files:X,matched:Y,unknown:Z,hasPreset:Q}=await w(K,{base:z,readSources:b(z,u.ignore)},n));try{W=te(V,z)}catch(n){let r=S.get(l.name);if(!(r?.id===B&&ne(r.packagePresetSpecifiers,V)&&r.packagePresetDependencies.some(e=>!t(e,{throwIfNoEntry:!1}))))throw n;W=r.packagePresetDependencies,e.logger.warn(`@teacss/rsbuild: keeping the last valid package preset dependencies for ${B} while package entries are unavailable`)}$=Array.from(new Set([...W,...n.sources]))}else{q??=await C(l.name);let e=await y(u,q.generator,void 0,q.sources),{spliceEntry:t}=await import(`@teacss/directives`);J=t(K,e.css),Y=e.utilities,X=e.files,$=q.sources}Q||e.logger.warn(`@teacss/rsbuild: ${k||`entry`} declares no @preset — no utilities generated. Add one, e.g. \`@preset "standard";\``),Z.length&&e.logger.warn(`@teacss/rsbuild: ${Z.length} @custom var(s) not registered (unknown namespace / illegal color step): ${Z.join(`, `)}`);for(let e of X)_(e);for(let e of $)m(e,_,E,D);let ie=(l.config.mode??a.env.NODE_ENV)===`production`;if(!(r??ie))return e.logger.info(`@teacss/rsbuild: ${Y} utilities (dev, unoptimized) → ${(J.length/1024).toFixed(1)}KB`),G(),{code:J};let ae=typeof r==`object`&&r.minify!==void 0?r.minify:O(l.config.output.minify,ie),{css:oe,skipped:se}=await T(J,{minify:ae,targets:o,browserslist:l.browserslist});return e.logger.info(`@teacss/rsbuild: ${Y} utilities${se?`, ${se} skipped`:``} → ${(oe.length/1024).toFixed(1)}KB`),G(),{code:oe}})}}}export{d as DEFAULT_TARGETS,v as generate,C as generateEntryCss,b as makeReadSources,T as optimize,P as pluginTeacss,O as resolveMinify,N as transformCss};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teacss/rsbuild",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Rsbuild integration for TeaCSS — generate utilities and optimize with lightningcss, no PostCSS.",
|
|
5
5
|
"homepage": "https://css.teasim.com",
|
|
6
6
|
"funding": "https://github.com/sponsors/billgo",
|
|
@@ -22,18 +22,19 @@
|
|
|
22
22
|
"dev": "tsdown --watch"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@teacss/config": "0.3.
|
|
26
|
-
"@teacss/core": "0.3.
|
|
27
|
-
"@teacss/directives": "0.3.
|
|
28
|
-
"@teacss/runtime": "0.3.
|
|
25
|
+
"@teacss/config": "0.3.1",
|
|
26
|
+
"@teacss/core": "0.3.1",
|
|
27
|
+
"@teacss/directives": "0.3.1",
|
|
28
|
+
"@teacss/runtime": "0.3.1",
|
|
29
29
|
"lightningcss": "^1.33.0",
|
|
30
30
|
"magic-string": "^1.1.0",
|
|
31
31
|
"tinyglobby": "^0.2.17"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rsbuild/core": "^2.1.8",
|
|
35
|
-
"@teacss/preset-articles": "0.3.
|
|
36
|
-
"@teacss/preset-standard": "0.3.
|
|
35
|
+
"@teacss/preset-articles": "0.3.1",
|
|
36
|
+
"@teacss/preset-standard": "0.3.1",
|
|
37
|
+
"consola": "^3.4.2"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"@rsbuild/core": "^2"
|