@navecss/core 0.5.0 → 0.6.0
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 +38 -9
- package/dist/bin.js +3 -3
- package/dist/{chunk-63H2FLGU.js → chunk-B5CWZIBK.js} +1 -1
- package/dist/{chunk-BCUK4M4P.js → chunk-EYMFWE3A.js} +1866 -56
- package/dist/{chunk-MWHZ26S4.js → chunk-KDLLTOAM.js} +6 -34
- package/dist/{chunk-KKUYU75D.js → chunk-R6R5DSTT.js} +1 -1
- package/dist/collect.d.ts +309 -13
- package/dist/collect.js +37 -1
- package/dist/lightningcss.js +3 -3
- package/dist/postcss.js +2 -2
- package/dist/vite.js +109 -914
- package/package.json +11 -12
- package/skills/navecss/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -182,7 +182,7 @@ without a new warning, it says what to move, and it always shows how to mark the
|
|
|
182
182
|
directive if the later value is meant to win:
|
|
183
183
|
|
|
184
184
|
```text
|
|
185
|
-
src/panel.css:3:3: @nave: display: grid comes after "hideDesktopUp", so under @media (width >= 75em) display is grid, not none.
|
|
185
|
+
src/panel.css:3:3: @nave: display: grid comes after "hideDesktopUp", so under @media (width >= 75em) display is grid, not none. To let "hideDesktopUp" win, move display: grid above the directive. If it is meant to win, mark the directive that names "hideDesktopUp": `@nave /* nave-allow-override: display */ hideDesktopUp;`
|
|
186
186
|
```
|
|
187
187
|
|
|
188
188
|
Where no move clears the warning, as when the later value comes from another atom's
|
|
@@ -198,8 +198,7 @@ changing its exit code. No option turns it off for the whole project.
|
|
|
198
198
|
A directive written inside a nested rule that applies to the same element, such as
|
|
199
199
|
`.card { & { @nave hideDesktopUp } display: flex; }`, is checked the same way: its atoms' blocks
|
|
200
200
|
are compared with what follows the directive inside that nested rule, and with what each
|
|
201
|
-
enclosing rule holds after the nested rule.
|
|
202
|
-
earlier releases, because that later content already won in them.
|
|
201
|
+
enclosing rule holds after the nested rule.
|
|
203
202
|
|
|
204
203
|
**Marking an override you mean.** Name the property in a comment inside the
|
|
205
204
|
directive:
|
|
@@ -326,7 +325,9 @@ Every custom property Nave declares is in the stylesheet you already installed,
|
|
|
326
325
|
|
|
327
326
|
On Vite, use the Vite plugin: it is the one route this package teaches for Vite, and for Astro,
|
|
328
327
|
which builds with Vite ([Astro](#astro) has its config). On
|
|
329
|
-
Next.js,
|
|
328
|
+
Next.js, use [`@navecss/prune`](https://github.com/navecss/navecss/tree/main/packages/prune#readme)
|
|
329
|
+
to ship only the atoms the build can read a use for, or the PostCSS plugin to keep every atom. On
|
|
330
|
+
webpack, or any other pipeline that runs PostCSS plugins, use the PostCSS plugin. A host
|
|
330
331
|
that runs Lightning CSS directly uses [the Lightning CSS adapter](#lightning-css-adapter-setup),
|
|
331
332
|
and a project with no bundler uses [`navecss-core expand`](#navecss-core-expand).
|
|
332
333
|
|
|
@@ -594,16 +595,27 @@ list: with an empty list, or none, it fails the build. Each client build records
|
|
|
594
595
|
`nave-used-atoms.json` file described below, the atoms it read from each listed package's calls,
|
|
595
596
|
where the calls it could not read are, and any `keepFor` key that names no package the build read.
|
|
596
597
|
|
|
597
|
-
`keepFor` stands in for the package's own calls, never for a call your code makes, so
|
|
598
|
+
`keepFor` stands in for the package's own calls, never for a call your code makes, so four problems
|
|
598
599
|
in a listed package still fail the build. A module of the package that re-exports `cx` under the
|
|
599
600
|
name `cx` still fails when a file of yours imports `cx` from that module itself, in an `import` or
|
|
600
601
|
`export ... from` statement, or a dependency that does more than re-export it imports it from there,
|
|
601
602
|
and the report gives the `cxModules` entry that lets the build read those calls. Through a module
|
|
602
603
|
that only re-exports it, such as the package's own entry file or another package, a listed module
|
|
603
604
|
would be two steps away, so there the report names each file of yours that takes it: import `cx`
|
|
604
|
-
from `@navecss/core/cx` there instead. A module that
|
|
605
|
-
|
|
606
|
-
|
|
605
|
+
from `@navecss/core/cx` there instead. A CommonJS module that forwards it with
|
|
606
|
+
`module.exports = require(...)` or `exports.cn = require(...).cn`, or with what TypeScript emits for
|
|
607
|
+
`export { cn } from` and `export * from` when it compiles to CommonJS, counts as one that only
|
|
608
|
+
re-exports it. A module that gives `cx` out under another name, as a default
|
|
609
|
+
or inside a namespace, or by assigning it first (`export const cn = cx`), still fails when your code
|
|
610
|
+
takes that export, and the report names each file of yours that does: import `cx` from
|
|
611
|
+
`@navecss/core/cx` there instead. A module of the package that uses `cx` where the build cannot
|
|
612
|
+
follow it to an export, such as `obj.cn = cx`, `memo(cx)` or `{ cn: cx }`, or that takes a module
|
|
613
|
+
holding a `cx` export in a way the build reads neither as calls only nor as a forward,
|
|
614
|
+
such as the CommonJS that Babel, esbuild or Rollup write for `export * from`, fails whenever it is
|
|
615
|
+
part of the build, whatever your code takes from the package, because the build cannot tell whether
|
|
616
|
+
a call of yours goes through it. The report names the file and the form. The fix is the package's,
|
|
617
|
+
in a release of it or a patched copy: export `cx` by name from an ES module. Until then, ship every
|
|
618
|
+
atom (below). And a module of the package
|
|
607
619
|
that you list in `cxModules` but that does not re-export Nave's `cx` under that name still fails:
|
|
608
620
|
remove it from `cxModules`.
|
|
609
621
|
|
|
@@ -619,6 +631,11 @@ A class your code takes at run time from `@navecss/core/atoms` (`atomClassMap[va
|
|
|
619
631
|
`toClassName('grid')`) is one the build does not read: it neither reads nor refuses it, so list its
|
|
620
632
|
atom in `keep`.
|
|
621
633
|
|
|
634
|
+
A package listed in `keepFor` can give `cx` to your code without the build failing if it redefines
|
|
635
|
+
or adds a method on `Function.prototype` or `Object.prototype`, or declares its own function under
|
|
636
|
+
one of the names compilers reserve for their interop helpers, such as `__importStar`: the build
|
|
637
|
+
cannot see either.
|
|
638
|
+
|
|
622
639
|
If your pages are rendered outside the build, by a backend that serves its own templates and uses
|
|
623
640
|
Vite for its assets only, the build reads none of their classes. While `keep` is empty, the plugin
|
|
624
641
|
warns when it has read no HTML page, no server render and no use of Nave at all: no `cx()` call, no
|
|
@@ -628,7 +645,9 @@ templates use in `keep`, or, if they are many, ship every atom (below).
|
|
|
628
645
|
|
|
629
646
|
The PostCSS plugin and the Lightning CSS adapter read no `cx()` call and leave every atom in the
|
|
630
647
|
layer, on Next.js and webpack alike; so does a page with no bundler, which links the standalone
|
|
631
|
-
stylesheet.
|
|
648
|
+
stylesheet. On Next.js,
|
|
649
|
+
[`@navecss/prune`](https://github.com/navecss/navecss/tree/main/packages/prune#readme) ships only
|
|
650
|
+
the atoms its build can read a use for.
|
|
632
651
|
|
|
633
652
|
A server build leaves packages in `node_modules` external by default, so it does not read their
|
|
634
653
|
code. For such a package that depends on `@navecss/core`, the build warns, naming it, unless it is
|
|
@@ -806,6 +825,10 @@ If you are using only `cx()` or tokens, you do not need to install it.
|
|
|
806
825
|
|
|
807
826
|
#### Next.js
|
|
808
827
|
|
|
828
|
+
To ship only the atoms the build can read a use for, use
|
|
829
|
+
[`@navecss/prune`](https://github.com/navecss/navecss/tree/main/packages/prune#readme) in place of
|
|
830
|
+
this plugin. The setup below keeps every atom.
|
|
831
|
+
|
|
809
832
|
Next.js reads a PostCSS plugin by its package name, so give it the name as a key and do not
|
|
810
833
|
call `navePlugin()`:
|
|
811
834
|
|
|
@@ -1134,3 +1157,9 @@ Consumers of `@navecss/tokens` alone get no guide: it ships only in this package
|
|
|
1134
1157
|
| `@navecss/core/postcss` | PostCSS plugin — `navePlugin()` |
|
|
1135
1158
|
| `@navecss/core/check` | The survival check as a function — `check({ source })` |
|
|
1136
1159
|
| `@navecss/core/collect` | Reads which atoms a module uses and trims the atom layer to them, for build tools; not meant for application code |
|
|
1160
|
+
|
|
1161
|
+
## Trademark
|
|
1162
|
+
|
|
1163
|
+
This package is not affiliated with, endorsed by or sponsored by Vercel or the Next.js project.
|
|
1164
|
+
|
|
1165
|
+
Vercel, the Vercel design, Next.js and related marks, designs and logos are trademarks or registered trademarks of Vercel, Inc. or its affiliates in the US and other countries.
|
package/dist/bin.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { runCheck } from './chunk-CTFEYJBE.js';
|
|
3
3
|
import { splitByteOrderMark } from './chunk-2TNTYI4L.js';
|
|
4
|
-
import { foldedText, orderWarningTexts } from './chunk-
|
|
4
|
+
import { foldedText, orderWarningTexts } from './chunk-R6R5DSTT.js';
|
|
5
5
|
import { formatFinding } from './chunk-ZNTNLGEC.js';
|
|
6
|
-
import { validateExtendAtomsHostFree } from './chunk-
|
|
6
|
+
import { validateExtendAtomsHostFree } from './chunk-B5CWZIBK.js';
|
|
7
7
|
import { resolveExtendSpecifier, applyExtendModule } from './chunk-NKUZNRF4.js';
|
|
8
|
-
import { snapshotExtendMap, expandText } from './chunk-
|
|
8
|
+
import { snapshotExtendMap, expandText } from './chunk-KDLLTOAM.js';
|
|
9
9
|
import { createPositionFinder, atKeywordName } from './chunk-UVHGEVMV.js';
|
|
10
10
|
import './chunk-SYNQJNVB.js';
|
|
11
11
|
import './chunk-CUL5PLPI.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { walkExtendAtoms, hasEscapedCommentOpener, isOnlyInert, hasTopLevelComment, hasUnstrippedTrailingSpace, hasUnstrippedLeadingSpace, lastNonWhitespace, isInert, hasPaddedComment, hasBrokenString, hasUrl, hasStrayCurlyCloser, anchorSelectorList, hasEscapedWhitespace, hasHtmlBreakout, hasTopLevelColon } from './chunk-
|
|
1
|
+
import { walkExtendAtoms, hasEscapedCommentOpener, isOnlyInert, hasTopLevelComment, hasUnstrippedTrailingSpace, hasUnstrippedLeadingSpace, lastNonWhitespace, isInert, hasPaddedComment, hasBrokenString, hasUrl, hasStrayCurlyCloser, anchorSelectorList, hasEscapedWhitespace, hasHtmlBreakout, hasTopLevelColon } from './chunk-KDLLTOAM.js';
|
|
2
2
|
import { matchBrackets, readItem } from './chunk-UVHGEVMV.js';
|
|
3
3
|
import { tokenize } from './chunk-2K5EBBF2.js';
|
|
4
4
|
|