diff --git a/.changepacks/changepack_log_css_license_banner.json b/.changepacks/changepack_log_css_license_banner.json new file mode 100644 index 000000000..16e5faae8 --- /dev/null +++ b/.changepacks/changepack_log_css_license_banner.json @@ -0,0 +1,14 @@ +{ + "changes": { + "bindings/devup-ui-binding/package.json": "Patch", + "bindings/devup-ui-wasm/package.json": "Patch", + "packages/plugin-utils/package.json": "Patch", + "packages/vite-plugin/package.json": "Patch", + "packages/webpack-plugin/package.json": "Patch", + "packages/next-plugin/package.json": "Patch", + "packages/rsbuild-plugin/package.json": "Patch", + "packages/bun-plugin/package.json": "Patch" + }, + "note": "Stylesheets without any rule are emitted empty instead of as a bare license banner, so the empty shared base sheet no longer repeats the banner in every per-file stylesheet that imports it. The banner names the version without a trailing comma (`v1.0.83`, not `v1.0.83,`). A new `licenseBanner` plugin option (default `true`) and the `setLicenseBanner`/`isLicenseBanner` engine functions turn the banner off; both engines emit identical output.", + "date": "2026-11-17T00:00:00.000Z" +} diff --git a/README.md b/README.md index 64cb06e99..609936b02 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ const example =
; With CSS: ```css -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */.b{background:red}.c{padding:16px}.a:hover{background:blue} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */.b{background:red}.c{padding:16px}.a:hover{background:blue} ``` **Dynamic values become CSS variables:** @@ -159,7 +159,7 @@ const example =
; With CSS: ```css -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */.a{background:var(--b)} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */.a{background:var(--b)} ``` **Complex expressions and responsive arrays:** @@ -182,7 +182,7 @@ const example =
; CSS: ```css -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */.b{background:red}.c{padding:16px}.a:hover{background:blue} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */.b{background:red}.c{padding:16px}.a:hover{background:blue} ``` **동적 값은 CSS 변수로 변환:** @@ -159,7 +159,7 @@ const example =
; CSS: ```css -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */.a{background:var(--b)} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */.a{background:var(--b)} ``` **복잡한 표현식과 반응형 배열:** @@ -182,7 +182,7 @@ const example =
Generated CSS: ```text -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */@keyframes a{from{opacity:0}to{opacity:1}}.b{animation:a 1s linear} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */@keyframes a{from{opacity:0}to{opacity:1}}.b{animation:a 1s linear} ``` ## Font Family Extraction @@ -141,7 +141,7 @@ const text = Generated CSS: ```text -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */.a{font-family:Inter} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */.a{font-family:Inter} ``` ## Style Deduplication @@ -175,7 +175,7 @@ const repeated =
Generated CSS: ```text -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */.a{background:red}.b{color:white} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */.a{background:red}.b{color:white} ``` These three elements share two rules. Reuse reduces repeated CSS without adding diff --git a/apps/landing/src/app/(detail)/docs/installation/page.ko.mdx b/apps/landing/src/app/(detail)/docs/installation/page.ko.mdx index bce5c53c1..eb98ea748 100644 --- a/apps/landing/src/app/(detail)/docs/installation/page.ko.mdx +++ b/apps/landing/src/app/(detail)/docs/installation/page.ko.mdx @@ -147,6 +147,29 @@ await Bun.build({ }) ``` +## 라이선스 배너 + +Devup UI가 내보내는 모든 스타일시트는 +`/*! devup-ui v… | Apache License 2.0 | https://devup-ui.com */` 주석으로 +시작하며, 압축기도 이 주석을 남깁니다. 기본값은 켜짐입니다. 모든 빌드 플러그인은 +`licenseBanner` 옵션을 받으며, `licenseBanner: false`로 설정하면 모든 +스타일시트에서 배너를 뺍니다. 규칙이 하나도 없는 스타일시트는 배너 없이 빈 +파일로 내보냅니다. + +```ts +// next.config.ts +export default DevupUI(nextConfig, { licenseBanner: false }) + +// vite.config.ts +DevupUI({ licenseBanner: false }) + +// rsbuild.config.ts +DevupUIRsbuildPlugin({ licenseBanner: false }) + +// webpack.config.js +new DevupUIWebpackPlugin({ licenseBanner: false }) +``` + ## 프로젝트 예제 - [Next.js 예제](https://github.com/dev-five-git/devup-ui/tree/main/apps/next) diff --git a/apps/landing/src/app/(detail)/docs/installation/page.mdx b/apps/landing/src/app/(detail)/docs/installation/page.mdx index 030cf3900..49415187a 100644 --- a/apps/landing/src/app/(detail)/docs/installation/page.mdx +++ b/apps/landing/src/app/(detail)/docs/installation/page.mdx @@ -148,6 +148,28 @@ await Bun.build({ }) ``` +## License Banner + +Every stylesheet Devup UI emits starts with a +`/*! devup-ui v… | Apache License 2.0 | https://devup-ui.com */` comment, which +minifiers keep. It is on by default. Every build plugin takes a +`licenseBanner` option; `licenseBanner: false` drops the banner from every +stylesheet. A stylesheet without any rule is emitted empty, banner included. + +```ts +// next.config.ts +export default DevupUI(nextConfig, { licenseBanner: false }) + +// vite.config.ts +DevupUI({ licenseBanner: false }) + +// rsbuild.config.ts +DevupUIRsbuildPlugin({ licenseBanner: false }) + +// webpack.config.js +new DevupUIWebpackPlugin({ licenseBanner: false }) +``` + ## Project Examples - [Next.js Example](https://github.com/dev-five-git/devup-ui/tree/main/apps/next) diff --git a/apps/landing/src/app/(detail)/docs/migration/vanilla-extract/page.ko.mdx b/apps/landing/src/app/(detail)/docs/migration/vanilla-extract/page.ko.mdx index 0778b8973..115398de9 100644 --- a/apps/landing/src/app/(detail)/docs/migration/vanilla-extract/page.ko.mdx +++ b/apps/landing/src/app/(detail)/docs/migration/vanilla-extract/page.ko.mdx @@ -74,7 +74,7 @@ export const a = "a"; 테마가 비어 있으면 같은 예제에서 다음 CSS가 생성됩니다: ```text -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */@layer b;@layer b{body{margin:0}}.a{color:red} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */@layer b;@layer b{body{margin:0}}.a{color:red} ``` 생성되는 이름은 클래스 접두사와 추출 상태에 따라 달라집니다. vanilla-extract API import는 제거되지만, 생성된 CSS import는 남습니다. @@ -101,7 +101,7 @@ export const button = "b c"; 생성된 CSS: ```text -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */.c{color:blue}.a{color:red}.b{padding:8px} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */.c{color:blue}.a{color:red}.b{padding:8px} ``` `button`에는 충돌하는 red 클래스가 포함되지 않습니다. 빌드 시점에 알 수 없는 외부 클래스는 여전히 CSS 캐스케이드를 따르며, 클래스 이름 문자열의 순서가 덮어쓰기 규칙이 되지는 않습니다. diff --git a/apps/landing/src/app/(detail)/docs/migration/vanilla-extract/page.mdx b/apps/landing/src/app/(detail)/docs/migration/vanilla-extract/page.mdx index 4f6d04fcb..f7eae6af9 100644 --- a/apps/landing/src/app/(detail)/docs/migration/vanilla-extract/page.mdx +++ b/apps/landing/src/app/(detail)/docs/migration/vanilla-extract/page.mdx @@ -76,7 +76,7 @@ export const a = "a"; With an empty theme, the same probe emits: ```text -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */@layer b;@layer b{body{margin:0}}.a{color:red} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */@layer b;@layer b{body{margin:0}}.a{color:red} ``` Generated names depend on the class prefix and extraction state. The @@ -107,7 +107,7 @@ export const button = "b c"; Generated CSS: ```text -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */.c{color:blue}.a{color:red}.b{padding:8px} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */.c{color:blue}.a{color:red}.b{padding:8px} ``` `button` does not include the conflicting red class. Unknown external classes diff --git a/benchmark/next-devup-ui-collapse/next.config.ts b/benchmark/next-devup-ui-collapse/next.config.ts index 5af9af04e..b9c7fdd9f 100644 --- a/benchmark/next-devup-ui-collapse/next.config.ts +++ b/benchmark/next-devup-ui-collapse/next.config.ts @@ -2,4 +2,4 @@ import { DevupUI } from '@devup-ui/next-plugin' const nextConfig = { experimental: { useTypeScriptCli: true } } -export default DevupUI(nextConfig, {}) +export default DevupUI(nextConfig, { licenseBanner: false }) diff --git a/benchmark/next-devup-ui-large-turbo-wasm/next.config.ts b/benchmark/next-devup-ui-large-turbo-wasm/next.config.ts index db41da922..edf01d83d 100644 --- a/benchmark/next-devup-ui-large-turbo-wasm/next.config.ts +++ b/benchmark/next-devup-ui-large-turbo-wasm/next.config.ts @@ -2,4 +2,4 @@ import { DevupUI } from '@devup-ui/next-plugin' const nextConfig = { experimental: { useTypeScriptCli: true } } -export default DevupUI(nextConfig, { engine: 'wasm' }) +export default DevupUI(nextConfig, { engine: 'wasm', licenseBanner: false }) diff --git a/benchmark/next-devup-ui-large-turbo/next.config.ts b/benchmark/next-devup-ui-large-turbo/next.config.ts index 5af9af04e..b9c7fdd9f 100644 --- a/benchmark/next-devup-ui-large-turbo/next.config.ts +++ b/benchmark/next-devup-ui-large-turbo/next.config.ts @@ -2,4 +2,4 @@ import { DevupUI } from '@devup-ui/next-plugin' const nextConfig = { experimental: { useTypeScriptCli: true } } -export default DevupUI(nextConfig, {}) +export default DevupUI(nextConfig, { licenseBanner: false }) diff --git a/benchmark/next-devup-ui-large-wasm/next.config.ts b/benchmark/next-devup-ui-large-wasm/next.config.ts index db41da922..edf01d83d 100644 --- a/benchmark/next-devup-ui-large-wasm/next.config.ts +++ b/benchmark/next-devup-ui-large-wasm/next.config.ts @@ -2,4 +2,4 @@ import { DevupUI } from '@devup-ui/next-plugin' const nextConfig = { experimental: { useTypeScriptCli: true } } -export default DevupUI(nextConfig, { engine: 'wasm' }) +export default DevupUI(nextConfig, { engine: 'wasm', licenseBanner: false }) diff --git a/benchmark/next-devup-ui-large/next.config.ts b/benchmark/next-devup-ui-large/next.config.ts index 5af9af04e..b9c7fdd9f 100644 --- a/benchmark/next-devup-ui-large/next.config.ts +++ b/benchmark/next-devup-ui-large/next.config.ts @@ -2,4 +2,4 @@ import { DevupUI } from '@devup-ui/next-plugin' const nextConfig = { experimental: { useTypeScriptCli: true } } -export default DevupUI(nextConfig, {}) +export default DevupUI(nextConfig, { licenseBanner: false }) diff --git a/benchmark/next-devup-ui-single-turbo/next.config.mjs b/benchmark/next-devup-ui-single-turbo/next.config.mjs index 8b2b3bf05..02282a967 100644 --- a/benchmark/next-devup-ui-single-turbo/next.config.mjs +++ b/benchmark/next-devup-ui-single-turbo/next.config.mjs @@ -5,4 +5,4 @@ import { DevupUI } from '@devup-ui/next-plugin' /** @satisfies {import('next').NextConfig} */ const nextConfig = { experimental: { useTypeScriptCli: true } } -export default DevupUI(nextConfig, { singleCss: true }) +export default DevupUI(nextConfig, { singleCss: true, licenseBanner: false }) diff --git a/benchmark/next-devup-ui-single/next.config.ts b/benchmark/next-devup-ui-single/next.config.ts index 978420890..9cc919ea8 100644 --- a/benchmark/next-devup-ui-single/next.config.ts +++ b/benchmark/next-devup-ui-single/next.config.ts @@ -2,4 +2,4 @@ import { DevupUI } from '@devup-ui/next-plugin' const nextConfig = { experimental: { useTypeScriptCli: true } } -export default DevupUI(nextConfig, { singleCss: true }) +export default DevupUI(nextConfig, { singleCss: true, licenseBanner: false }) diff --git a/benchmark/next-devup-ui-turbo/next.config.ts b/benchmark/next-devup-ui-turbo/next.config.ts index 5af9af04e..b9c7fdd9f 100644 --- a/benchmark/next-devup-ui-turbo/next.config.ts +++ b/benchmark/next-devup-ui-turbo/next.config.ts @@ -2,4 +2,4 @@ import { DevupUI } from '@devup-ui/next-plugin' const nextConfig = { experimental: { useTypeScriptCli: true } } -export default DevupUI(nextConfig, {}) +export default DevupUI(nextConfig, { licenseBanner: false }) diff --git a/benchmark/next-devup-ui/next.config.ts b/benchmark/next-devup-ui/next.config.ts index 5af9af04e..b9c7fdd9f 100644 --- a/benchmark/next-devup-ui/next.config.ts +++ b/benchmark/next-devup-ui/next.config.ts @@ -2,4 +2,4 @@ import { DevupUI } from '@devup-ui/next-plugin' const nextConfig = { experimental: { useTypeScriptCli: true } } -export default DevupUI(nextConfig, {}) +export default DevupUI(nextConfig, { licenseBanner: false }) diff --git a/benchmark/next-stylex-turbo-devup-ui/next.config.mjs b/benchmark/next-stylex-turbo-devup-ui/next.config.mjs index bbd839d60..bfd980ac8 100644 --- a/benchmark/next-stylex-turbo-devup-ui/next.config.mjs +++ b/benchmark/next-stylex-turbo-devup-ui/next.config.mjs @@ -2,5 +2,5 @@ import { DevupUI } from '@devup-ui/next-plugin' export default DevupUI( { experimental: { useTypeScriptCli: true } }, - { singleCss: true }, + { singleCss: true, licenseBanner: false }, ) diff --git a/benchmark/next-tailwind-turbo-devup-ui/next.config.mjs b/benchmark/next-tailwind-turbo-devup-ui/next.config.mjs index e0668cb13..4c863044d 100644 --- a/benchmark/next-tailwind-turbo-devup-ui/next.config.mjs +++ b/benchmark/next-tailwind-turbo-devup-ui/next.config.mjs @@ -1,3 +1,6 @@ import { DevupUI } from '@devup-ui/next-plugin' -export default DevupUI({ experimental: { useTypeScriptCli: true } }) +export default DevupUI( + { experimental: { useTypeScriptCli: true } }, + { licenseBanner: false }, +) diff --git a/benchmark/next-vanilla-extract-devup-ui/next.config.mjs b/benchmark/next-vanilla-extract-devup-ui/next.config.mjs index e0668cb13..4c863044d 100644 --- a/benchmark/next-vanilla-extract-devup-ui/next.config.mjs +++ b/benchmark/next-vanilla-extract-devup-ui/next.config.mjs @@ -1,3 +1,6 @@ import { DevupUI } from '@devup-ui/next-plugin' -export default DevupUI({ experimental: { useTypeScriptCli: true } }) +export default DevupUI( + { experimental: { useTypeScriptCli: true } }, + { licenseBanner: false }, +) diff --git a/benchmark/vinext-devup-ui/vite.config.ts b/benchmark/vinext-devup-ui/vite.config.ts index e46db26c8..ad07fd6d1 100644 --- a/benchmark/vinext-devup-ui/vite.config.ts +++ b/benchmark/vinext-devup-ui/vite.config.ts @@ -3,5 +3,5 @@ import vinext from 'vinext' import { defineConfig } from 'vite' export default defineConfig({ - plugins: [DevupUI(), vinext()], + plugins: [DevupUI({ licenseBanner: false }), vinext()], }) diff --git a/bindings/argument-validation.cjs b/bindings/argument-validation.cjs index a0e3edb41..7b9f5b658 100644 --- a/bindings/argument-validation.cjs +++ b/bindings/argument-validation.cjs @@ -22,6 +22,7 @@ module.exports = function createBoundary() { seedFileMap: 'files:a', setAtomHoist: 'threshold:n', setDebug: 'debug:b', + setLicenseBanner: 'enabled:b', setModuleResolver: 'resolver:f', setPrefix: 'prefix:p', } diff --git a/bindings/devup-ui-binding/README.md b/bindings/devup-ui-binding/README.md index 71afa1212..54ae52197 100644 --- a/bindings/devup-ui-binding/README.md +++ b/bindings/devup-ui-binding/README.md @@ -96,4 +96,4 @@ The decoder is private and target-bounded: unused Serde hints use trait forwardi Malformed-enum error paths follow shipped serde-wasm-bindgen 0.6.5: Object.entries result length is read and coerced once for the check, then read and coerced again for the invalid-length diagnostic when the first length is not one, before any index read. The second value supplies the diagnostic; errors thrown by its getter or coercion propagate unchanged. Valid enums retain one length read. -The shared native/WASM boundary validates ordinary calls at 46 argument positions in 19 functions: malformed inputs throw a genuine `TypeError` naming the function, parameter and required type before state mutation. Preflight defaults the entire alias map on schema failure (after diagnostics) or a caught iterator-import failure whose `new Error(String(error))` conversion succeeds. Raw access failures and conversion faults escape unchanged before resolver selection; conversion runs once with the pending failure cleared, so reentry is isolated and resolver changes take effect before the outer core starts. Extraction and reservation remain strict. For example, `setPrefix(false)` throws `setPrefix(): argument prefix must be a string, null or undefined`; string/nullish prefixes remain supported. Extraction wrappers retain the measured metadata, receiver, extra-argument and apply/construct policy; `seedFileMap` validates and copies the caller's array before engine entry without rereading its indices. Same-revision Node/Bun identity, 272-case invalid-input, 73-exception preservation and seed-safety gates cover these contracts, not optimized shipping-native performance or real Node-host Linux Rust/authored-JS 100% coverage, which remain public-delivery gates. +The shared native/WASM boundary validates ordinary calls at 47 argument positions in 20 functions: malformed inputs throw a genuine `TypeError` naming the function, parameter and required type before state mutation. Preflight defaults the entire alias map on schema failure (after diagnostics) or a caught iterator-import failure whose `new Error(String(error))` conversion succeeds. Raw access failures and conversion faults escape unchanged before resolver selection; conversion runs once with the pending failure cleared, so reentry is isolated and resolver changes take effect before the outer core starts. Extraction and reservation remain strict. For example, `setPrefix(false)` throws `setPrefix(): argument prefix must be a string, null or undefined`; string/nullish prefixes remain supported. Extraction wrappers retain the measured metadata, receiver, extra-argument and apply/construct policy; `seedFileMap` validates and copies the caller's array before engine entry without rereading its indices. Same-revision Node/Bun identity, 276-case invalid-input, 73-exception preservation and seed-safety gates cover these contracts, not optimized shipping-native performance or real Node-host Linux Rust/authored-JS 100% coverage, which remain public-delivery gates. diff --git a/bindings/devup-ui-binding/adapter.cjs b/bindings/devup-ui-binding/adapter.cjs index a34c93cac..db16d73fe 100644 --- a/bindings/devup-ui-binding/adapter.cjs +++ b/bindings/devup-ui-binding/adapter.cjs @@ -100,6 +100,7 @@ exports.createBinding = function createBinding(raw) { importFileRoutes: (value) => call(raw.importFileRoutes, value), importSheet: (value) => call(raw.importSheet, value), isDebug: raw.isDebug, + isLicenseBanner: raw.isLicenseBanner, registerShorthands: (value) => call(raw.registerShorthands, value), registerTheme: (value) => call(raw.registerTheme, value), removeFile: (filename) => raw.removeFile(filename), @@ -110,6 +111,7 @@ exports.createBinding = function createBinding(raw) { seedFileMap, setAtomHoist: (value) => raw.setAtomHoist(index(value)), setDebug: (value) => raw.setDebug(value), + setLicenseBanner: (value) => raw.setLicenseBanner(value), setModuleResolver, setPrefix: (value) => raw.setPrefix(value == null ? undefined : value), }) diff --git a/bindings/devup-ui-binding/index.d.cts b/bindings/devup-ui-binding/index.d.cts index eae4ba96a..842bb21d8 100644 --- a/bindings/devup-ui-binding/index.d.cts +++ b/bindings/devup-ui-binding/index.d.cts @@ -63,6 +63,8 @@ export function importFileMap(value: unknown): void export function importFileRoutes(value: unknown): void export function importSheet(value: unknown): void export function isDebug(): boolean +/** Whether emitted stylesheets start with the license banner (on by default). */ +export function isLicenseBanner(): boolean export function registerShorthands(value: unknown): void export function registerTheme(value: unknown): void /** Forget a deleted source file's own styles; whether the sheet changed. */ @@ -80,6 +82,8 @@ export function resetStateForTesting(): void export function seedFileMap(files: string[]): void export function setAtomHoist(threshold?: number | null): void export function setDebug(debug: boolean): void +/** Turn the license banner of emitted stylesheets on or off. */ +export function setLicenseBanner(enabled: boolean): void export function setModuleResolver( resolver?: | (( diff --git a/bindings/devup-ui-binding/index.mjs b/bindings/devup-ui-binding/index.mjs index 015b58724..1524fd3f0 100644 --- a/bindings/devup-ui-binding/index.mjs +++ b/bindings/devup-ui-binding/index.mjs @@ -20,6 +20,7 @@ export const { importFileRoutes, importSheet, isDebug, + isLicenseBanner, registerShorthands, registerTheme, removeFile, @@ -29,6 +30,7 @@ export const { seedFileMap, setAtomHoist, setDebug, + setLicenseBanner, setModuleResolver, setPrefix, } = binding diff --git a/bindings/devup-ui-binding/src/lib.rs b/bindings/devup-ui-binding/src/lib.rs index 7211b6d16..8fdd217e2 100644 --- a/bindings/devup-ui-binding/src/lib.rs +++ b/bindings/devup-ui-binding/src/lib.rs @@ -205,6 +205,16 @@ pub fn set_debug(value: bool) { pub fn is_debug() -> bool { core::is_debug() } +/// Turn the license banner of emitted stylesheets on or off. +#[napi] +pub fn set_license_banner(value: bool) { + core::set_license_banner(value); +} +/// Read whether emitted stylesheets carry the license banner. +#[napi] +pub fn is_license_banner() -> bool { + core::is_license_banner() +} /// Set hoisting after facade nullish/unsigned-i32 conversion. #[napi] pub fn set_atom_hoist(value: Option) { diff --git a/bindings/devup-ui-wasm/AGENTS.md b/bindings/devup-ui-wasm/AGENTS.md index 0a26113a8..1fcd3f3c9 100644 --- a/bindings/devup-ui-wasm/AGENTS.md +++ b/bindings/devup-ui-wasm/AGENTS.md @@ -22,6 +22,7 @@ Rust → WebAssembly → JavaScript bridge. Exposes extraction engine to build p ### Configuration - `setPrefix()/getPrefix()` - Class name prefix - `setDebug()/isDebug()` - Debug mode +- `setLicenseBanner()/isLicenseBanner()` - License banner of emitted stylesheets (on by default) ## OUTPUT STRUCTURE diff --git a/bindings/devup-ui-wasm/README.md b/bindings/devup-ui-wasm/README.md index 066708bcf..c794b4e03 100644 --- a/bindings/devup-ui-wasm/README.md +++ b/bindings/devup-ui-wasm/README.md @@ -23,21 +23,22 @@ repository root fails if one does. Everything is exported from `pkg/index.js` (types in `pkg/index.d.ts`). -| Function | Does | -| ----------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Function | Does | +| ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `codeExtract(filename, code, package, cssDir, singleCss, importMainCssInCode, importMainCssInCss, importAliases)` | Compiles one source file and returns an `Output`: the rewritten `code`, its `css`, `cssFile`, source `map`, the `dependencies` it read and `updatedBaseStyle`. Throws on a build error. | -| `codeExtractWithoutSourceMap(...)` | The same without the source map. | -| `hasDevupUI(filename, code, package)` | Whether the file imports Devup UI, so a plugin can skip the rest. | -| `getCss(fileNum, importMainCss)` | The stylesheet collected so far: the whole sheet for `null`, one file's for its number. | +| `codeExtractWithoutSourceMap(...)` | The same without the source map. | +| `hasDevupUI(filename, code, package)` | Whether the file imports Devup UI, so a plugin can skip the rest. | +| `getCss(fileNum, importMainCss)` | The stylesheet collected so far: the whole sheet for `null`, one file's for its number. | | `removeFile(filename)` | Forgets a deleted source file: its global CSS, its own stylesheet and the class names handed out in it. Returns whether the sheet changed. | -| `registerTheme(theme)`, `registerShorthands(shorthands)` | Registers the `devup.json` theme and the custom shorthand props before extracting. | -| `getThemeInterface(package, color, typography, length, shadows, theme)` | The `.d.ts` text that types the registered theme. | -| `getDefaultTheme()` | The theme variant that applies without `data-theme`. | -| `setPrefix(prefix)`, `getPrefix()` | Class name prefix. | -| `setDebug(debug)`, `isDebug()` | Readable class names instead of base-37 ones, with repeated declarations kept (the tests run this way). | -| `setModuleResolver(resolver)` | `(specifier, importer) => ({ path, code })`: how imports are resolved, so imported stylesheets are evaluated and imported constants inlined. | -| `setAtomHoist(threshold)`, `importFileRoutes(routes)` | Moves atoms used by `threshold` routes or more into the shared sheet. Call before `codeExtract`. | -| `exportSheet`, `exportClassMap`, `exportFileMap`, `exportCanonicalMap` and the matching `import*` functions | Save the collected state and load it into another process, as a bundler does between its server and client builds. | +| `registerTheme(theme)`, `registerShorthands(shorthands)` | Registers the `devup.json` theme and the custom shorthand props before extracting. | +| `getThemeInterface(package, color, typography, length, shadows, theme)` | The `.d.ts` text that types the registered theme. | +| `getDefaultTheme()` | The theme variant that applies without `data-theme`. | +| `setPrefix(prefix)`, `getPrefix()` | Class name prefix. | +| `setDebug(debug)`, `isDebug()` | Readable class names instead of base-37 ones, with repeated declarations kept (the tests run this way). | +| `setLicenseBanner(enabled)`, `isLicenseBanner()` | Whether every stylesheet starts with the `/*! devup-ui v… */` license banner. On by default. A stylesheet without any rule is emitted empty either way. | +| `setModuleResolver(resolver)` | `(specifier, importer) => ({ path, code })`: how imports are resolved, so imported stylesheets are evaluated and imported constants inlined. | +| `setAtomHoist(threshold)`, `importFileRoutes(routes)` | Moves atoms used by `threshold` routes or more into the shared sheet. Call before `codeExtract`. | +| `exportSheet`, `exportClassMap`, `exportFileMap`, `exportCanonicalMap` and the matching `import*` functions | Save the collected state and load it into another process, as a bundler does between its server and client builds. | ## State diff --git a/bindings/devup-ui-wasm/script.js b/bindings/devup-ui-wasm/script.js index 7bc343dff..4cf3cbebc 100644 --- a/bindings/devup-ui-wasm/script.js +++ b/bindings/devup-ui-wasm/script.js @@ -50,9 +50,9 @@ types = types.replace(hookType, '') assert.equal(types.includes('install_panic_hook'), false) writeFileSync('pkg/index.d.ts', types, 'utf8') const names = [...source.matchAll(/^exports\.(\w+) = \1;/gm)] -assert.equal(names.length, 30) -assert.equal(new Set(names.map((match) => match[1])).size, 30) -assert.equal([...source.matchAll(/^exports\./gm)].length, 30) +assert.equal(names.length, 32) +assert.equal(new Set(names.map((match) => match[1])).size, 32) +assert.equal([...source.matchAll(/^exports\./gm)].length, 32) assert.equal(source.includes('module.exports'), false) for (const name of ['codeExtract', 'codeExtractWithoutSourceMap']) { const signatures = [ diff --git a/bindings/devup-ui-wasm/src/lib.rs b/bindings/devup-ui-wasm/src/lib.rs index ab8f2c6b7..9f67f61c6 100644 --- a/bindings/devup-ui-wasm/src/lib.rs +++ b/bindings/devup-ui-wasm/src/lib.rs @@ -156,6 +156,17 @@ pub fn is_debug() -> bool { binding_core::is_debug() } +#[wasm_bindgen(js_name = "setLicenseBanner")] +pub fn set_license_banner(enabled: bool) { + binding_core::set_license_banner(enabled); +} + +#[wasm_bindgen(js_name = "isLicenseBanner")] +#[must_use] +pub fn is_license_banner() -> bool { + binding_core::is_license_banner() +} + /// Set the CSS class name prefix /// /// # Example (Vite Config) @@ -932,10 +943,8 @@ mod tests { let mut sheet = GLOBAL_STYLE_SHEET.lock().unwrap(); *sheet = StyleSheet::default(); } - assert_eq!( - get_css(None, false).unwrap().split("*/").nth(1).unwrap(), - "" - ); + // An empty sheet is emitted empty, without even the banner + assert_eq!(get_css(None, false).unwrap(), ""); { let mut sheet = GLOBAL_STYLE_SHEET.lock().unwrap(); @@ -1262,6 +1271,17 @@ mod tests { assert!(!is_debug()); } + #[test] + #[serial] + fn test_license_banner() { + let _state = TestStateGuard::new(); + assert!(is_license_banner()); + set_license_banner(false); + assert!(!is_license_banner()); + set_license_banner(true); + assert!(is_license_banner()); + } + #[test] #[serial] fn test_prefix() { diff --git a/e2e/binding/corpus/boundary.mjs b/e2e/binding/corpus/boundary.mjs index c7dd0a5a6..c781819e7 100644 --- a/e2e/binding/corpus/boundary.mjs +++ b/e2e/binding/corpus/boundary.mjs @@ -24,11 +24,14 @@ add('numeric-wrapper-and-boolean-abi', (h) => { h.call('setAtomHoist', value) h.call('getCss', value, false) h.call('setDebug', value) + h.call('setLicenseBanner', value) h.extract(source, { flags: [value, value, value] }) } h.call('setAtomHoist') h.call('getCss') h.call('setDebug') + h.call('setLicenseBanner') + h.call('setLicenseBanner', true) }) add('decoder-width-overflow-and-enums', (h) => { for (const value of [ diff --git a/e2e/binding/corpus/state.mjs b/e2e/binding/corpus/state.mjs index 85f5e8b64..a9db54b3e 100644 --- a/e2e/binding/corpus/state.mjs +++ b/e2e/binding/corpus/state.mjs @@ -68,6 +68,7 @@ add('distinct-resets-and-resolver-teardown', (h) => { h.call('registerTheme', theme) h.call('registerShorthands', { insetX: ['left', 'right'] }) h.call('setDebug', true) + h.call('setLicenseBanner', false) h.call('setPrefix', 'dirty-') h.call('setAtomHoist', 2) h.call('setModuleResolver', (...args) => { diff --git a/e2e/binding/host.mjs b/e2e/binding/host.mjs index a86141ce5..cd2b59587 100644 --- a/e2e/binding/host.mjs +++ b/e2e/binding/host.mjs @@ -68,7 +68,7 @@ save('provenance.json', { scenarios: corpus.map((c) => c.name), }) const names = - 'Output codeExtract codeExtractWithoutSourceMap exportCanonicalMap exportClassMap exportFileMap exportSheet getCss getDefaultTheme getPrefix getThemeInterface getUnreservedClassSlotCount hasDevupUI importCanonicalMap importClassMap importFileMap importFileRoutes importSheet isDebug registerShorthands registerTheme removeFile reserveClassSlots resetBuildState resetStateForTesting seedFileMap setAtomHoist setDebug setModuleResolver setPrefix'.split( + 'Output codeExtract codeExtractWithoutSourceMap exportCanonicalMap exportClassMap exportFileMap exportSheet getCss getDefaultTheme getPrefix getThemeInterface getUnreservedClassSlotCount hasDevupUI importCanonicalMap importClassMap importFileMap importFileRoutes importSheet isDebug isLicenseBanner registerShorthands registerTheme removeFile reserveClassSlots resetBuildState resetStateForTesting seedFileMap setAtomHoist setDebug setLicenseBanner setModuleResolver setPrefix'.split( ' ', ) const abi = { @@ -117,6 +117,7 @@ const snapshot = () => ({ [ 'getPrefix', 'isDebug', + 'isLicenseBanner', 'getDefaultTheme', 'getUnreservedClassSlotCount', ].map((name) => [name, capture(() => w[name]())]), diff --git a/e2e/binding/package/consumer.mjs b/e2e/binding/package/consumer.mjs index 3940b9cca..1de06ad40 100644 --- a/e2e/binding/package/consumer.mjs +++ b/e2e/binding/package/consumer.mjs @@ -136,7 +136,7 @@ export async function consume(options) { ] .map((match) => match[1]) .sort() - assert.equal(names.length, 30) + assert.equal(names.length, 32) for (const manager of ['npm', 'bun']) { for (const omit of [false, true]) { const startRequest = server.requests.length diff --git a/e2e/binding/validation-cases.mjs b/e2e/binding/validation-cases.mjs index f69d04387..b443f1822 100644 --- a/e2e/binding/validation-cases.mjs +++ b/e2e/binding/validation-cases.mjs @@ -47,6 +47,7 @@ export const positions = [ ['seedFileMap', 'files:seed', () => [['src/new.tsx']]], ['setAtomHoist', 'threshold:n', () => [2]], ['setDebug', 'debug:b', () => [true]], + ['setLicenseBanner', 'enabled:b', () => [false]], ['setModuleResolver', 'resolver:resolver', () => [null]], ['setPrefix', 'prefix:prefix', () => ['valid-']], ].flatMap(([fn, slots, args]) => @@ -154,6 +155,6 @@ export const cases = positions.flatMap((position) => .map((good, index) => (index === position.index ? value : good)), })), ) -assert.equal(positions.length, 46) -assert.equal(new Set(positions.map((p) => p.fn)).size, 19) +assert.equal(positions.length, 47) +assert.equal(new Set(positions.map((p) => p.fn)).size, 20) assert.equal(new Set(cases.map((c) => c.id)).size, cases.length) diff --git a/e2e/binding/validation-host.mjs b/e2e/binding/validation-host.mjs index 94eade6b6..c071e186d 100644 --- a/e2e/binding/validation-host.mjs +++ b/e2e/binding/validation-host.mjs @@ -47,6 +47,7 @@ const extract = (filename, text) => { w.resetStateForTesting() w.setPrefix('kept-') w.setDebug(true) +w.setLicenseBanner(false) w.registerTheme(theme) w.registerShorthands({ insetX: ['left', 'right'] }) w.importCanonicalMap({ 'src/kept.tsx': 'src/root.tsx' }) @@ -71,6 +72,7 @@ const snapshot = () => ({ config: [ 'getPrefix', 'isDebug', + 'isLicenseBanner', 'getDefaultTheme', 'getUnreservedClassSlotCount', ].map((name) => capture(() => w[name]())), diff --git a/e2e/binding/wasm-abi/coverage.test.mjs b/e2e/binding/wasm-abi/coverage.test.mjs index 2f715c781..84056ad8b 100644 --- a/e2e/binding/wasm-abi/coverage.test.mjs +++ b/e2e/binding/wasm-abi/coverage.test.mjs @@ -157,6 +157,6 @@ test('exempts only the documented unvalidated parameters', () => { test('the validation oracle covers every documented argument position', () => { const positions = new Set(cases.map((item) => `${item.fn}.${item.parameter}`)) - assert.equal(positions.size, 46) + assert.equal(positions.size, 47) for (const key of Object.keys(UNVALIDATED)) assert.ok(!positions.has(key)) }) diff --git a/libs/binding/src/css_cache.rs b/libs/binding/src/css_cache.rs index c6fdda54f..ee1ab4bbc 100644 --- a/libs/binding/src/css_cache.rs +++ b/libs/binding/src/css_cache.rs @@ -11,8 +11,9 @@ use std::ops::{Deref, DerefMut}; use std::sync::{LazyLock, LockResult, Mutex, MutexGuard, PoisonError}; /// What a serialization reads besides the sheet: the bucket, whether a file -/// stylesheet imports the shared base, and whether atom hoisting is in effect. -type Key = (Option, bool, bool); +/// stylesheet imports the shared base, whether atom hoisting is in effect, and +/// whether the license banner is on. +type Key = (Option, bool, bool, bool); static CSS_CACHE: LazyLock>> = LazyLock::new(Mutex::default); @@ -26,6 +27,7 @@ fn key(bucket: Option<&str>, import_main_css: bool) -> Key { bucket.map(str::to_string), bucket.is_some() && import_main_css, css::atom_hoist::is_atom_hoist(), + css::license_banner::is_license_banner(), ) } @@ -100,6 +102,23 @@ mod tests { assert_ne!(key(Some("a.tsx"), true), key(Some("a.tsx"), false)); } + #[test] + #[serial_test::serial] + fn the_license_banner_setting_keys_a_serialization() { + let _state = css::test_state::TestStateGuard::new(); + invalidate_css(); + let mut sheet = StyleSheet::default(); + sheet.add_property("a", "color", 0, "red", None, Some(255), None); + let with_banner = cached_css(&sheet, None, false); + assert!(with_banner.starts_with("/*! devup-ui v")); + // A serialization cached with the banner is not served without it + css::license_banner::set_license_banner(false); + assert_eq!(cached_css(&sheet, None, false), ".a{color:red}"); + css::license_banner::set_license_banner(true); + assert_eq!(cached_css(&sheet, None, false), with_banner); + invalidate_css(); + } + #[test] fn a_poisoned_sheet_stays_usable() { let cell = SheetCell::default(); diff --git a/libs/binding/src/lib.rs b/libs/binding/src/lib.rs index 2377453df..8cf075474 100644 --- a/libs/binding/src/lib.rs +++ b/libs/binding/src/lib.rs @@ -8,6 +8,7 @@ mod resolver_state; pub mod session; pub use css::debug::{is_debug, set_debug}; +pub use css::license_banner::{is_license_banner, set_license_banner}; pub use css::slot_reservation::unreserved_slot_count as get_unreserved_class_slot_count; pub use css::{get_prefix, set_custom_shorthands as register_shorthands_internal, set_prefix}; pub use css_cache::{SheetCell, SheetGuard}; diff --git a/libs/binding/src/session/tests.rs b/libs/binding/src/session/tests.rs index 173d20e88..698522062 100644 --- a/libs/binding/src/session/tests.rs +++ b/libs/binding/src/session/tests.rs @@ -99,6 +99,35 @@ fn sessions_keep_their_own_numbering_settings_and_sheet() { assert!(css.is_ok_and(|css| css.contains("color:blue") && css.contains("--brand"))); } +#[test] +#[serial] +fn the_license_banner_setting_belongs_to_one_session() { + let _clean = clean(); + // Given: session 0 turned the banner off and both sessions hold styles + crate::set_license_banner(false); + extract("zero.tsx", "red"); + let session = create_session(); + // When: the other session runs + let css = with_session(session, || { + // Then: it starts with the banner on and emits it + assert!(crate::is_license_banner()); + extract("other.tsx", "blue"); + get_css(None, false) + }); + assert!(css.is_ok_and(|css| css.starts_with("/*! devup-ui v"))); + // And: session 0 keeps its own setting once it is live again + assert!(!crate::is_license_banner()); + assert!(get_css(None, false).starts_with(".a{color:red}")); + // And: turning it off in the other session stays there + assert_eq!( + with_session(session, || crate::set_license_banner(false)), + Ok(()) + ); + crate::set_license_banner(true); + assert_eq!(with_session(session, crate::is_license_banner), Ok(false)); + assert!(crate::is_license_banner()); +} + #[test] #[serial] fn removing_a_file_forgets_it_only_in_the_live_session() { diff --git a/libs/css/src/engine_state.rs b/libs/css/src/engine_state.rs index b4752fc82..f3fb4a2d0 100644 --- a/libs/css/src/engine_state.rs +++ b/libs/css/src/engine_state.rs @@ -5,18 +5,21 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::sync::atomic::Ordering; use crate::{ - atom_hoist, class_map, debug, file_map, file_routes, slot_reservation, tailwind_definitions, - theme_tokens, + atom_hoist, class_map, debug, file_map, file_routes, license_banner, slot_reservation, + tailwind_definitions, theme_tokens, }; -/// The prefix, debug flag, atom hoisting, class and file numbering, routes, -/// shorthands, theme tokens and Tailwind definitions of one engine session. +/// The prefix, debug and license banner flags, atom hoisting, class and file +/// numbering, routes, shorthands, theme tokens and Tailwind definitions of one +/// engine session. /// /// The default value is a clean engine, as after a full reset. #[derive(Default)] pub struct CssState { prefix: Option, debug: bool, + /// Stored inverted so that the default state keeps the banner on. + license_banner_off: bool, hoist: Option, plan: Option>, reservation: slot_reservation::State, @@ -37,6 +40,11 @@ impl CssState { crate::set_prefix(std::mem::replace(&mut self.prefix, prefix)); let debug = debug::is_debug(); debug::set_debug(std::mem::replace(&mut self.debug, debug)); + let banner_off = !license_banner::is_license_banner(); + license_banner::set_license_banner(!std::mem::replace( + &mut self.license_banner_off, + banner_off, + )); let hoist = atom_hoist::atom_hoist_threshold(); atom_hoist::set_atom_hoist(std::mem::replace(&mut self.hoist, hoist)); let plan = atom_hoist::atom_plan(); diff --git a/libs/css/src/lib.rs b/libs/css/src/lib.rs index 1e8ff692b..7dd26932a 100644 --- a/libs/css/src/lib.rs +++ b/libs/css/src/lib.rs @@ -10,6 +10,7 @@ pub mod engine_state; pub mod file_map; pub mod file_routes; pub mod is_special_property; +pub mod license_banner; mod num_to_nm_base; pub mod optimize_multi_css_value; pub mod optimize_value; diff --git a/libs/css/src/license_banner.rs b/libs/css/src/license_banner.rs new file mode 100644 index 000000000..e7784f20a --- /dev/null +++ b/libs/css/src/license_banner.rs @@ -0,0 +1,34 @@ +//! Whether emitted stylesheets start with the `/*! devup-ui ... */` license banner. + +use std::sync::atomic::{AtomicBool, Ordering}; + +static LICENSE_BANNER: AtomicBool = AtomicBool::new(true); + +/// Turn the license banner of emitted stylesheets on or off (on by default). +#[inline(always)] +pub fn set_license_banner(value: bool) { + LICENSE_BANNER.store(value, Ordering::Relaxed); +} + +/// Whether emitted stylesheets start with the license banner. +#[inline(always)] +pub fn is_license_banner() -> bool { + LICENSE_BANNER.load(Ordering::Relaxed) +} + +#[cfg(test)] +mod tests { + use super::*; + use serial_test::serial; + + #[test] + #[serial] + fn test_set_license_banner() { + let _state = crate::test_state::TestStateGuard::new(); + assert!(is_license_banner()); + set_license_banner(false); + assert!(!is_license_banner()); + set_license_banner(true); + assert!(is_license_banner()); + } +} diff --git a/libs/css/src/test_state.rs b/libs/css/src/test_state.rs index 597b2850b..3da5183b5 100644 --- a/libs/css/src/test_state.rs +++ b/libs/css/src/test_state.rs @@ -6,14 +6,15 @@ use std::marker::PhantomData; use std::rc::Rc; use crate::{ - atom_hoist, class_map, debug, engine_state::CssState, file_map, file_routes, slot_reservation, - tailwind_definitions, theme_tokens, + atom_hoist, class_map, debug, engine_state::CssState, file_map, file_routes, license_banner, + slot_reservation, tailwind_definitions, theme_tokens, }; /// Reset CSS-owned persistent state without retaining a snapshot. pub fn reset_state_for_testing() { crate::set_prefix(None); debug::set_debug(false); + license_banner::set_license_banner(true); atom_hoist::set_atom_hoist(None); atom_hoist::restore_atom_plan(None); slot_reservation::reset(); diff --git a/libs/css/src/test_state/tests.rs b/libs/css/src/test_state/tests.rs index 57805e6a8..d839ae46b 100644 --- a/libs/css/src/test_state/tests.rs +++ b/libs/css/src/test_state/tests.rs @@ -6,6 +6,7 @@ use std::sync::atomic::Ordering; fn seed() { crate::set_prefix(Some("outer".into())); debug::set_debug(true); + license_banner::set_license_banner(false); atom_hoist::set_atom_hoist(Some(3)); class_map::set_class_map(HashMap::from([( "x".into(), @@ -36,6 +37,7 @@ fn seed() { fn assert_seed() { assert_eq!(crate::get_prefix().as_deref(), Some("outer")); assert!(debug::is_debug()); + assert!(!license_banner::is_license_banner()); assert_eq!(atom_hoist::atom_hoist_threshold(), Some(3)); assert_eq!(class_map::get_class_map()["x"]["y"], 7); assert_eq!(file_map::get_file_map().len(), 1); @@ -79,6 +81,7 @@ fn assert_seed() { fn assert_clean() { assert_eq!(crate::get_prefix(), None); assert!(!debug::is_debug()); + assert!(license_banner::is_license_banner()); assert_eq!(atom_hoist::atom_hoist_threshold(), None); assert_eq!(class_map::get_class_map(), HashMap::new()); assert_eq!(file_map::get_file_map().len(), 0); diff --git a/libs/extractor/README.md b/libs/extractor/README.md index 706dcfd13..be757364a 100644 --- a/libs/extractor/README.md +++ b/libs/extractor/README.md @@ -34,7 +34,7 @@ function Example({ variable }: { Generated CSS: ```css -/*! devup-ui v1.0.82, | Apache License 2.0 | https://devup-ui.com */.a{background:red}.b{color:white}.c{margin:8px}.d{padding:8px}.e{text-align:var(--f)} +/*! devup-ui v1.0.82 | Apache License 2.0 | https://devup-ui.com */.a{background:red}.b{color:white}.c{margin:8px}.d{padding:8px}.e{text-align:var(--f)} ``` ```mermaid diff --git a/libs/sheet/src/lib.rs b/libs/sheet/src/lib.rs index 4a3478516..1bca058ac 100644 --- a/libs/sheet/src/lib.rs +++ b/libs/sheet/src/lib.rs @@ -178,20 +178,40 @@ static VAR_RE: LazyLock = LazyLock::new(|| compile_regex(r"\$\w[\w.-]*")) static INTERFACE_KEY_RE: LazyLock = LazyLock::new(|| compile_regex(r"^[a-zA-Z_$][a-zA-Z0-9_$]*$")); -/// Cached header string — computed once from compile-time included package.json +/// Cached header string — computed once from compile-time included package.json. +/// The version is the published npm version of `@devup-ui/wasm` (the Cargo +/// crates stay at `0.1.0`); both engines build this crate, so they share it. static HEADER: LazyLock = LazyLock::new(|| { format!( "/*! devup-ui v{version} | Apache License 2.0 | https://devup-ui.com */", - version = include_str!("../../../bindings/devup-ui-wasm/package.json") - .lines() - .find(|line| line.contains("\"version\"")) - .and_then(|line| line.split(':').nth(1)) - .unwrap_or("\"unknown\"") - .trim() - .replace('"', ""), + version = package_version(include_str!("../../../bindings/devup-ui-wasm/package.json")), ) }); +/// The `version` field of a `package.json` manifest, or `unknown` without one +fn package_version(manifest: &str) -> String { + serde_json::from_str::(manifest) + .ok() + .and_then(|manifest| manifest.get("version")?.as_str().map(str::to_owned)) + .unwrap_or_else(|| "unknown".to_string()) +} + +/// The license banner, or nothing when the build turned it off +fn license_header(enabled: bool) -> &'static str { + if enabled { &HEADER } else { "" } +} + +/// A sheet without any rule is emitted empty rather than as a bare banner. The +/// shared base sheet is `@import`ed by every per-file sheet, so a banner-only +/// base would put the banner twice into one stylesheet chain. +fn without_bare_header(css: String, header: &str) -> String { + if css.len() == header.len() { + String::new() + } else { + css + } +} + fn convert_interface_key(key: &str) -> Cow<'_, str> { if INTERFACE_KEY_RE.is_match(key) { Cow::Borrowed(key) @@ -1302,13 +1322,14 @@ impl StyleSheet { #[inline] fn create_header() -> &'static str { - &HEADER + license_header(css::license_banner::is_license_banner()) } #[must_use] pub fn create_css(&self, filename: Option<&str>, import_main_css: bool) -> String { let mut css = String::with_capacity(4096); - css.push_str(Self::create_header()); + let header = Self::create_header(); + css.push_str(header); // An import written again takes effect where it is written last let imports: Vec<&String> = self.imports.values().flatten().collect(); for (index, import) in imports.iter().enumerate() { @@ -1563,7 +1584,7 @@ impl StyleSheet { } } } - css + without_bare_header(css, header) } } @@ -1670,6 +1691,70 @@ mod tests { assert_eq!(convert_theme_variable_value(input), expected); } + #[rstest] + #[case(r#"{"name":"a","version":"1.0.83","b":1}"#, "1.0.83")] + #[case("{\n \"version\": \"2.3.4\",\n \"x\": 1\n}", "2.3.4")] + #[case(r#"{"name":"a"}"#, "unknown")] + #[case(r#"{"version":1}"#, "unknown")] + #[case("not json", "unknown")] + fn test_package_version(#[case] manifest: &str, #[case] expected: &str) { + assert_eq!(package_version(manifest), expected); + } + + #[test] + fn test_header_names_the_published_version() { + // `@devup-ui/wasm`'s package.json holds the npm version; the old line + // split left the JSON comma in it (`v1.0.83,`). + let version = package_version(include_str!("../../../bindings/devup-ui-wasm/package.json")); + assert!( + compile_regex(r"^\d+\.\d+\.\d+").is_match(&version), + "{version}" + ); + assert_eq!( + license_header(true), + format!("/*! devup-ui v{version} | Apache License 2.0 | https://devup-ui.com */") + ); + assert_eq!(license_header(false), ""); + } + + #[test] + fn test_without_bare_header() { + assert_eq!(without_bare_header(HEADER.clone(), &HEADER), ""); + assert_eq!(without_bare_header(String::new(), ""), ""); + assert_eq!( + without_bare_header(format!("{}a{{}}", *HEADER), &HEADER), + format!("{}a{{}}", *HEADER) + ); + } + + #[test] + #[serial] + fn test_license_banner_option() { + let _state = css::test_state::TestStateGuard::new(); + let mut sheet = StyleSheet::default(); + // A sheet without rules ships nothing, banner or not + assert_eq!(sheet.create_css(None, false), ""); + assert_eq!(sheet.create_css(Some("a.tsx"), false), ""); + sheet.add_property("a", "color", 0, "red", None, Some(255), None); + // On by default + let with_banner = sheet.create_css(None, false); + assert_eq!(with_banner, format!("{}.a{{color:red}}", *HEADER)); + // The per-file sheet keeps importing the shared base, banner or not + assert_eq!( + sheet.create_css(Some("other.tsx"), true), + format!("{}@import \"./devup-ui.css\";", *HEADER) + ); + css::license_banner::set_license_banner(false); + assert_eq!(sheet.create_css(None, false), ".a{color:red}"); + assert_eq!( + sheet.create_css(Some("other.tsx"), true), + "@import \"./devup-ui.css\";" + ); + assert_eq!(sheet.create_css(Some("other.tsx"), false), ""); + css::license_banner::set_license_banner(true); + assert_eq!(sheet.create_css(None, false), with_banner); + } + #[test] #[serial] fn test_create_css_sort_test() { @@ -3036,7 +3121,15 @@ mod tests { assert_debug_snapshot!(sheet.create_css(None, false).split("*/").nth(1).unwrap()); sheet.rm_global_css("test.tsx", true); - assert_debug_snapshot!(sheet.create_css(None, false).split("*/").nth(1).unwrap()); + // Nothing is left, so the sheet is emitted empty, banner included + assert_eq!(sheet.create_css(None, false), ""); + assert_debug_snapshot!( + sheet + .create_css(None, false) + .split("*/") + .nth(1) + .unwrap_or_default() + ); let mut sheet = StyleSheet::default(); sheet.add_property( @@ -3986,11 +4079,8 @@ mod tests { let filename = if single_css { None } else { Some("test.tsx") }; let css = sheet.create_css(filename, false); if !single_css { - assert_eq!(sheet.create_css(None, false), StyleSheet::create_header()); - assert_eq!( - sheet.create_css(Some("other.tsx"), false), - StyleSheet::create_header() - ); + assert_eq!(sheet.create_css(None, false), ""); + assert_eq!(sheet.create_css(Some("other.tsx"), false), ""); } // Class names come from a process-wide counter; number them by first // appearance so the expected CSS only pins down structure and order. diff --git a/packages/bun-plugin/README.md b/packages/bun-plugin/README.md index 5eeb1e36f..9d37b9273 100644 --- a/packages/bun-plugin/README.md +++ b/packages/bun-plugin/README.md @@ -104,6 +104,17 @@ errors retain their cause and identify the missing platform package; they never silently select WASM. Each factory retains its selected compiler for later loads and theme reloads. Independent concurrent builds in one process are unsupported. +## License Banner + +Every emitted stylesheet starts with a +`/*! devup-ui v… | Apache License 2.0 | https://devup-ui.com */` comment, which +minifiers keep. It is on by default; `licenseBanner: false` drops it from every +stylesheet. A stylesheet without any rule is emitted empty, banner included. + +```ts +await register({ licenseBanner: false }) +``` + ## Custom Shorthands To configure custom shorthands, preload a local module instead of the diff --git a/packages/bun-plugin/src/__tests__/plugin.test.ts b/packages/bun-plugin/src/__tests__/plugin.test.ts index 0f7721dbd..90fde1acc 100644 --- a/packages/bun-plugin/src/__tests__/plugin.test.ts +++ b/packages/bun-plugin/src/__tests__/plugin.test.ts @@ -225,6 +225,20 @@ describe('registered Bun hooks', () => { expect(loads.length).toBe(2) }) + it('turns the license banner off only when asked to', async () => { + try { + await register({ engine: 'wasm', licenseBanner: false }) + expect(wasm.isLicenseBanner()).toBe(false) + await register({ engine: 'wasm', licenseBanner: true }) + expect(wasm.isLicenseBanner()).toBe(true) + wasm.setLicenseBanner(false) + await register({ engine: 'wasm' }) + expect(wasm.isLicenseBanner()).toBe(true) + } finally { + wasm.setLicenseBanner(true) + } + }) + it('warns when runtime file numbering fails, and stays quiet without src', async () => { const collect = spyOn(pluginUtils, 'collectNumberedFiles') const warn = spyOn(console, 'warn').mockImplementation(() => {}) diff --git a/packages/bun-plugin/src/plugin.ts b/packages/bun-plugin/src/plugin.ts index 22f131994..3b8c43d06 100644 --- a/packages/bun-plugin/src/plugin.ts +++ b/packages/bun-plugin/src/plugin.ts @@ -79,6 +79,11 @@ export interface DevupUIBunPluginOptions { * `false` in `Bun.build`. */ debug?: boolean + /** + * Start every emitted stylesheet with the devup-ui license banner comment. + * Defaults to `true`. + */ + licenseBanner?: boolean /** * Packages whose published `.js` files are compiled as well, as in the * other plugins: a library that ships Devup UI components uncompiled. @@ -272,6 +277,7 @@ function DevupUI(options: DevupUIBunPluginOptions = {}) { // this process left in the engine const endBuild = beginBuild(compiler) build.onEnd?.(endBuild) + compiler.setLicenseBanner(options.licenseBanner ?? true) await initialize(compiler, shorthands, watchTailwindCss, project) const debug = options.debug ?? !bundling compiler.setDebug(debug) diff --git a/packages/next-plugin/README.md b/packages/next-plugin/README.md index 8f3dadf79..5bb0513d1 100644 --- a/packages/next-plugin/README.md +++ b/packages/next-plugin/README.md @@ -243,6 +243,18 @@ original cause. There is no automatic fallback to WASM. Install optional native dependencies normally, or choose WASM explicitly for an unsupported platform. Both engines extract CSS during the build and add no client styling runtime. +## License banner + +Every emitted stylesheet starts with a +`/*! devup-ui v… | Apache License 2.0 | https://devup-ui.com */` comment, which +minifiers keep. It is on by default; `licenseBanner: false` drops it from every +stylesheet, under Webpack and Turbopack alike. A stylesheet without any rule is +emitted empty, banner included. + +```ts +export default DevupUI(nextConfig, { licenseBanner: false }) +``` + ## Turbopack build profiling Set `DEVUP_UI_PROFILE=1` for an opt-in, structured timing log during a diff --git a/packages/next-plugin/src/__tests__/plugin.test.ts b/packages/next-plugin/src/__tests__/plugin.test.ts index 12503aa10..c788fc23f 100644 --- a/packages/next-plugin/src/__tests__/plugin.test.ts +++ b/packages/next-plugin/src/__tests__/plugin.test.ts @@ -444,6 +444,16 @@ describe('DevupUINextPlugin', () => { }) }) + it('hands licenseBanner to the webpack plugin', () => { + DevupUI({}, { licenseBanner: false }).webpack!( + createWebpackConfig(), + createWebpackContext(), + ) + expect(devupUIWebpackPluginSpy).toHaveBeenCalledWith( + expect.objectContaining({ licenseBanner: false }), + ) + }) + it('reads routes from the project root when it holds app or pages', () => { // Given: a Next app with `app/` at the root and no `src/`. existsSyncSpy.mockImplementation( @@ -1211,6 +1221,27 @@ export const box = style({ color: 'red' })` DevupUI({}, { prefix: 'my-prefix' }) expect(setPrefixSpy).toHaveBeenCalledWith('my-prefix') }) + it.each([ + [undefined, true], + [true, true], + [false, false], + ] as const)( + 'sets the license banner from licenseBanner=%s under Turbopack', + (licenseBanner, expected) => { + process.env.TURBOPACK = '1' + using setLicenseBanner = spyOn( + wasm, + 'setLicenseBanner', + ).mockReturnValue(undefined) + existsSyncSpy + .mockReturnValueOnce(true) + .mockReturnValueOnce(true) + .mockReturnValueOnce(true) + .mockReturnValueOnce(false) + DevupUI({}, { licenseBanner }) + expect(setLicenseBanner).toHaveBeenCalledWith(expected) + }, + ) it('numbers the files the scan finds, and survives a failing scan', () => { process.env.TURBOPACK = '1' const collectSpy = spyOn(importGraphModule, 'collectNumberedFiles') diff --git a/packages/next-plugin/src/plugin.ts b/packages/next-plugin/src/plugin.ts index 7418bbfa3..21d7cdc3e 100644 --- a/packages/next-plugin/src/plugin.ts +++ b/packages/next-plugin/src/plugin.ts @@ -252,6 +252,7 @@ export function DevupUI( include = [], prefix, debug = false, + licenseBanner = true, atomHoist, importAliases: userImportAliases, } = options @@ -291,6 +292,7 @@ export function DevupUI( importAliases, include, libPackage, + licenseBanner, prefix, shorthands: normalizedShorthands, singleCss, @@ -347,6 +349,7 @@ export function DevupUI( registerShorthands, registerTheme, setDebug, + setLicenseBanner, setPrefix, } = wasm @@ -364,6 +367,7 @@ export function DevupUI( // After the restore: dropping a state that does not import resets these. setPrefix(prefix ?? null) setDebug(debug) + setLicenseBanner(licenseBanner) // Register current theme after importing previous state, // since importSheet replaces the entire sheet including its theme. diff --git a/packages/plugin-utils/src/__tests__/compiler-types.test.ts b/packages/plugin-utils/src/__tests__/compiler-types.test.ts index c6b757714..8e15dfbea 100644 --- a/packages/plugin-utils/src/__tests__/compiler-types.test.ts +++ b/packages/plugin-utils/src/__tests__/compiler-types.test.ts @@ -78,7 +78,7 @@ describe('compiler structural types', () => { Object.keys(compiler).filter( (key) => key !== 'Output' && key !== 'default', ), - ).toHaveLength(29) + ).toHaveLength(31) } finally { compiler.resetStateForTesting() } diff --git a/packages/plugin-utils/src/__tests__/wasm-abi.test.ts b/packages/plugin-utils/src/__tests__/wasm-abi.test.ts index 45390ebfc..195f26440 100644 --- a/packages/plugin-utils/src/__tests__/wasm-abi.test.ts +++ b/packages/plugin-utils/src/__tests__/wasm-abi.test.ts @@ -16,6 +16,7 @@ function saveState() { canonicalMap: JSON.parse(wasm.exportCanonicalMap()), css: wasm.getCss(null, false), debug: wasm.isDebug(), + licenseBanner: wasm.isLicenseBanner(), prefix: wasm.getPrefix(), } } @@ -26,6 +27,7 @@ function restoreState(state: ReturnType) { wasm.importFileMap(state.fileMap) wasm.importCanonicalMap(state.canonicalMap) wasm.setDebug(state.debug) + wasm.setLicenseBanner(state.licenseBanner) wasm.setPrefix(state.prefix ?? null) } @@ -60,6 +62,7 @@ describe('@devup-ui/wasm exports', () => { 'importFileRoutes', 'importSheet', 'isDebug', + 'isLicenseBanner', 'registerShorthands', 'registerTheme', 'removeFile', @@ -69,6 +72,7 @@ describe('@devup-ui/wasm exports', () => { 'seedFileMap', 'setAtomHoist', 'setDebug', + 'setLicenseBanner', 'setModuleResolver', 'setPrefix', ]) @@ -143,6 +147,26 @@ describe('@devup-ui/wasm extraction', () => { wasm.setPrefix(null) expect(wasm.getPrefix()).toBeUndefined() }) + + it('starts stylesheets with the license banner unless it is turned off', () => { + extract( + `import { Box } from '${PACKAGE}'\nexport const a = `, + 'banner.tsx', + ) + // The banner is on by default and names the published version + expect(wasm.isLicenseBanner()).toBe(true) + const css = wasm.getCss(null, false) + expect(css).toMatch( + /^\/\*! devup-ui v\d+\.\d+\.\d+ \| Apache License 2\.0 \| https:\/\/devup-ui\.com \*\/\S/, + ) + + wasm.setLicenseBanner(false) + expect(wasm.isLicenseBanner()).toBe(false) + expect(wasm.getCss(null, false)).toBe(css.slice(css.indexOf('*/') + 2)) + + wasm.setLicenseBanner(true) + expect(wasm.getCss(null, false)).toBe(css) + }) }) describe('@devup-ui/wasm theme', () => { diff --git a/packages/plugin-utils/src/shared.ts b/packages/plugin-utils/src/shared.ts index 1714c3649..0a7b0ec30 100644 --- a/packages/plugin-utils/src/shared.ts +++ b/packages/plugin-utils/src/shared.ts @@ -117,6 +117,12 @@ export interface DevupUIBasePluginOptions { include: string[] singleCss: boolean prefix?: string + /** + * Start every emitted stylesheet with the `/*! devup-ui v… | Apache License + * 2.0 | https://devup-ui.com *\/` comment, which minifiers keep. Defaults to + * `true`; `false` drops it from every stylesheet. + */ + licenseBanner?: boolean importAliases?: ImportAliases /** Build-time aliases that expand one style prop into multiple CSS properties. */ shorthands?: CustomShorthands diff --git a/packages/rsbuild-plugin/README.md b/packages/rsbuild-plugin/README.md index 8d6a0b590..b77ae4341 100644 --- a/packages/rsbuild-plugin/README.md +++ b/packages/rsbuild-plugin/README.md @@ -204,6 +204,17 @@ The selected compiler serves configuration, reservation, transforms and delayed watch/build callbacks together. Neither engine supports concurrent independent builds in the same process. +## License banner + +Every emitted stylesheet starts with a +`/*! devup-ui v… | Apache License 2.0 | https://devup-ui.com */` comment, which +minifiers keep. It is on by default; `licenseBanner: false` drops it from every +stylesheet. A stylesheet without any rule is emitted empty, banner included. + +```ts +DevupUI({ licenseBanner: false }) +``` + ## Project root Relative `devupFile`, `distDir` and `cssDir` paths, and the `tsconfig.json` the diff --git a/packages/rsbuild-plugin/src/__tests__/plugin.test.ts b/packages/rsbuild-plugin/src/__tests__/plugin.test.ts index 1efd2b635..3de427fae 100644 --- a/packages/rsbuild-plugin/src/__tests__/plugin.test.ts +++ b/packages/rsbuild-plugin/src/__tests__/plugin.test.ts @@ -1031,6 +1031,21 @@ const App = () => `, expect(setPrefixSpy).toHaveBeenCalledWith('my-prefix') }) + it.each([ + [undefined, true], + [true, true], + [false, false], + ] as const)( + 'sets the license banner from licenseBanner=%s', + async (licenseBanner, expected) => { + using setLicenseBanner = spyOn(wasm, 'setLicenseBanner').mockReturnValue( + undefined, + ) + await DevupUI({ licenseBanner }).setup(createSetupContext()) + expect(setLicenseBanner).toHaveBeenCalledWith(expected) + }, + ) + describe('deterministic file numbering', () => { it('sets the prefix every time, even without one', async () => { setPrefixSpy.mockClear() diff --git a/packages/rsbuild-plugin/src/plugin.ts b/packages/rsbuild-plugin/src/plugin.ts index fcabbcd74..12f10a321 100644 --- a/packages/rsbuild-plugin/src/plugin.ts +++ b/packages/rsbuild-plugin/src/plugin.ts @@ -38,7 +38,7 @@ const PLUGIN_NAME = 'devup-ui-rsbuild-plugin' export interface DevupUIRsbuildPluginOptions extends Pick< DevupUIBasePluginOptions, - 'engine' + 'engine' | 'licenseBanner' > { package: string cssDir: string @@ -147,6 +147,7 @@ export const DevupUI = ({ debug = false, singleCss = false, prefix, + licenseBanner = true, shorthands, engine, atomHoist = 2, @@ -182,6 +183,7 @@ export const DevupUI = ({ userImportAliases, readJsxImportSource(projectRoot), ) + compiler.setLicenseBanner(licenseBanner) if (!existsSync(distDir)) await mkdir(distDir, { recursive: true }) await writeFile(join(distDir, '.gitignore'), '*', 'utf-8') diff --git a/packages/vite-plugin/README.md b/packages/vite-plugin/README.md index c228ed843..9d7508373 100644 --- a/packages/vite-plugin/README.md +++ b/packages/vite-plugin/README.md @@ -202,6 +202,17 @@ engine selection. Configuration, reservation, transforms and delayed callbacks use the same selected compiler. Neither engine supports concurrent independent builds in one process; Vite environments within a build share its compiler state. +## License banner + +Every emitted stylesheet starts with a +`/*! devup-ui v… | Apache License 2.0 | https://devup-ui.com */` comment, which +minifiers keep. It is on by default; `licenseBanner: false` drops it from every +stylesheet. A stylesheet without any rule is emitted empty, banner included. + +```ts +DevupUI({ licenseBanner: false }) +``` + ## Project root Relative `devupFile`, `distDir` and `cssDir` paths, and the `tsconfig.json` the diff --git a/packages/vite-plugin/src/__tests__/plugin.test.ts b/packages/vite-plugin/src/__tests__/plugin.test.ts index ea7278df5..6207c2d2c 100644 --- a/packages/vite-plugin/src/__tests__/plugin.test.ts +++ b/packages/vite-plugin/src/__tests__/plugin.test.ts @@ -2460,6 +2460,21 @@ export const a =
` await plugin.configResolved() expect(setPrefixSpy).toHaveBeenCalledWith('my-prefix') }) + + it.each([ + [undefined, true], + [true, true], + [false, false], + ] as const)( + 'sets the license banner from licenseBanner=%s', + async (licenseBanner, expected) => { + using setLicenseBanner = spyOn(wasm, 'setLicenseBanner').mockReturnValue( + undefined, + ) + await createPlugin({ licenseBanner }).configResolved() + expect(setLicenseBanner).toHaveBeenCalledWith(expected) + }, + ) }) describe('module resolver', () => { diff --git a/packages/vite-plugin/src/plugin.ts b/packages/vite-plugin/src/plugin.ts index bf0037ec1..0481c44b8 100644 --- a/packages/vite-plugin/src/plugin.ts +++ b/packages/vite-plugin/src/plugin.ts @@ -264,7 +264,7 @@ function createCssChunkBuildOptions( export interface DevupUIPluginOptions extends Pick< DevupUIBasePluginOptions, - 'engine' + 'engine' | 'licenseBanner' > { package: string cssDir: string @@ -361,6 +361,7 @@ export function DevupUI({ include = [], singleCss = false, prefix, + licenseBanner = true, shorthands, engine, atomHoist = 2, @@ -407,6 +408,7 @@ export function DevupUI({ compiler.registerShorthands(normalizedShorthands) compiler.setDebug(debug) compiler.setPrefix(prefix ?? null) + compiler.setLicenseBanner(licenseBanner) } if (ownsEngine) configureEngine() // The relative options and the tsconfig belong to the project root, which diff --git a/packages/webpack-plugin/README.md b/packages/webpack-plugin/README.md index defcc9ac6..4c5a5f9af 100644 --- a/packages/webpack-plugin/README.md +++ b/packages/webpack-plugin/README.md @@ -207,6 +207,17 @@ Selection applies to the plugin, source loader, CSS loader and delayed build callbacks as one unit. Native state, like WASM state, does not support concurrent independent builds in the same process. +## License banner + +Every emitted stylesheet starts with a +`/*! devup-ui v… | Apache License 2.0 | https://devup-ui.com */` comment, which +minifiers keep. It is on by default; `licenseBanner: false` drops it from every +stylesheet. A stylesheet without any rule is emitted empty, banner included. + +```ts +new DevupUIWebpackPlugin({ licenseBanner: false }) +``` + ## Project root Relative `devupFile`, `distDir` and `cssDir` paths, the `tsconfig.json` the diff --git a/packages/webpack-plugin/src/__tests__/plugin.test.ts b/packages/webpack-plugin/src/__tests__/plugin.test.ts index c51fbbe94..fe57fd139 100644 --- a/packages/webpack-plugin/src/__tests__/plugin.test.ts +++ b/packages/webpack-plugin/src/__tests__/plugin.test.ts @@ -438,6 +438,7 @@ describe('devupUIWebpackPlugin', () => { debug: false, singleCss: false, engine: 'native', + licenseBanner: true, atomHoist: 2, }) }, @@ -481,6 +482,7 @@ describe('devupUIWebpackPlugin', () => { }) expect(loadDevupConfigSyncSpy).toHaveBeenCalledWith( join(context, 'devup.json'), + expect.any(Set), ) }) @@ -622,6 +624,7 @@ describe('devupUIWebpackPlugin', () => { ).toEqual({ ...options, engine: 'wasm', + licenseBanner: true, atomHoist: 2, }) }) @@ -1109,6 +1112,24 @@ describe('devupUIWebpackPlugin', () => { expect(setPrefixSpy).toHaveBeenCalledWith('my-prefix') }) + it.each([ + [undefined, true], + [true, true], + [false, false], + ] as const)( + 'sets the license banner from licenseBanner=%s', + (licenseBanner, expected) => { + using setLicenseBanner = spyOn(wasm, 'setLicenseBanner').mockReturnValue( + undefined, + ) + existsSyncSpy.mockReturnValue(false) + new DevupUIWebpackPlugin({ engine: 'wasm', licenseBanner }).apply( + asCompiler(createCompiler()), + ) + expect(setLicenseBanner).toHaveBeenCalledWith(expected) + }, + ) + describe('collapse + atomHoist pre-pass', () => { let buildCanonicalMapSpy: ReturnType let computeFileReachSpy: ReturnType diff --git a/packages/webpack-plugin/src/plugin.ts b/packages/webpack-plugin/src/plugin.ts index 3caae1e71..9f8b20f84 100644 --- a/packages/webpack-plugin/src/plugin.ts +++ b/packages/webpack-plugin/src/plugin.ts @@ -42,7 +42,7 @@ import { reconcileWatchCss } from './watch-css' export interface DevupUIWebpackPluginOptions extends Pick< DevupUIBasePluginOptions, - 'engine' + 'engine' | 'licenseBanner' > { package: string cssDir: string @@ -103,6 +103,7 @@ export class DevupUIWebpackPlugin { singleCss = false, engine = 'native', prefix, + licenseBanner = true, shorthands, atomHoist = 2, productionPrewarmFiles, @@ -130,6 +131,7 @@ export class DevupUIWebpackPlugin { singleCss, engine, prefix, + licenseBanner, shorthands, atomHoist, productionPrewarmFiles: undefined, @@ -340,6 +342,7 @@ export class DevupUIWebpackPlugin { this.locate(resolve(compiler.options.context ?? process.cwd())) this.compiler.setDebug(this.options.debug) this.compiler.setPrefix(this.options.prefix ?? null) + this.compiler.setLicenseBanner(this.options.licenseBanner !== false) this.compiler.registerShorthands(this.normalizedShorthands) if (!existsSync(this.options.distDir)) mkdirSync(this.options.distDir, { recursive: true })