@typestyles/next 0.0.0-unstable.de79e3a17eb1 → 0.0.0-unstable.df708abe489f

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 CHANGED
@@ -227,9 +227,11 @@ import { TypestylesStylesheet } from '@typestyles/next';
227
227
 
228
228
  ```tsx
229
229
  // app/page.tsx
230
- import { styles } from 'typestyles';
230
+ import { createTypeStyles } from 'typestyles';
231
231
 
232
- const button = styles.component('button', {
232
+ const { recipe } = createTypeStyles({ scopeId: 'app' });
233
+
234
+ const button = recipe('button', {
233
235
  base: {
234
236
  padding: '12px 24px',
235
237
  backgroundColor: '#0066ff',
@@ -252,8 +254,10 @@ export default function Home() {
252
254
  ### With Design Tokens
253
255
 
254
256
  ```tsx
255
- // app/tokens.ts
256
- import { tokens } from 'typestyles';
257
+ // app/styles.ts
258
+ import { createTypeStyles } from 'typestyles';
259
+
260
+ export const { recipe, tokens } = createTypeStyles({ scopeId: 'app' });
257
261
 
258
262
  export const colors = tokens.create('color', {
259
263
  primary: '#0066ff',
@@ -267,10 +271,9 @@ export const spacing = tokens.create('space', {
267
271
  });
268
272
 
269
273
  // app/page.tsx
270
- import { styles } from 'typestyles';
271
- import { colors, spacing } from './tokens';
274
+ import { recipe, colors, spacing } from './styles';
272
275
 
273
- const card = styles.component('card', {
276
+ const card = recipe('card', {
274
277
  base: {
275
278
  padding: spacing.md,
276
279
  backgroundColor: colors.primary,
@@ -287,9 +290,11 @@ export default function Page() {
287
290
 
288
291
  ```tsx
289
292
  // app/layout.tsx
290
- import { tokens } from 'typestyles';
293
+ import { createTypeStyles } from 'typestyles';
291
294
  import { getRegisteredCss } from '@typestyles/next';
292
295
 
296
+ const { tokens } = createTypeStyles({ scopeId: 'app' });
297
+
293
298
  const darkTheme = tokens.createTheme('dark', {
294
299
  base: {
295
300
  color: {
package/dist/build.cjs CHANGED
@@ -62,10 +62,11 @@ async function buildTypestylesForNext(options) {
62
62
  } = options;
63
63
  const resolvedModules = resolveExtractModulesForNext(root, modules);
64
64
  const enableRouteCss = options.routeCss ?? discoverNextAppRoutesEnabled(root, appDir);
65
+ let extractNonce = 0;
65
66
  const loaders = resolvedModules.map((mod) => {
66
67
  const abs = (0, import_node_path.resolve)(root, mod);
67
68
  const href = (0, import_node_url.pathToFileURL)(abs).href;
68
- return () => import(href);
69
+ return () => import(`${href}?typestyles-extract=${++extractNonce}`);
69
70
  });
70
71
  const css = await (0, import_build.collectStylesFromModules)(loaders);
71
72
  const outAbs = (0, import_node_path.resolve)(root, cssOutFile);
package/dist/build.js CHANGED
@@ -41,10 +41,11 @@ async function buildTypestylesForNext(options) {
41
41
  } = options;
42
42
  const resolvedModules = resolveExtractModulesForNext(root, modules);
43
43
  const enableRouteCss = options.routeCss ?? discoverNextAppRoutesEnabled(root, appDir);
44
+ let extractNonce = 0;
44
45
  const loaders = resolvedModules.map((mod) => {
45
46
  const abs = resolve(root, mod);
46
47
  const href = pathToFileURL(abs).href;
47
- return () => import(href);
48
+ return () => import(`${href}?typestyles-extract=${++extractNonce}`);
48
49
  });
49
50
  const css = await collectStylesFromModules(loaders);
50
51
  const outAbs = resolve(root, cssOutFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typestyles/next",
3
- "version": "0.0.0-unstable.de79e3a17eb1",
3
+ "version": "0.0.0-unstable.df708abe489f",
4
4
  "description": "Next.js integration for typestyles SSR",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -68,7 +68,7 @@
68
68
  }
69
69
  },
70
70
  "dependencies": {
71
- "@typestyles/build-runner": "0.0.0-unstable.de79e3a17eb1"
71
+ "@typestyles/build-runner": "0.0.0-unstable.df708abe489f"
72
72
  },
73
73
  "devDependencies": {
74
74
  "eslint": "^9.39.2",
@@ -80,7 +80,7 @@
80
80
  "react": "^18.0.0",
81
81
  "react-dom": "^18.0.0",
82
82
  "tsup": "^8.0.0",
83
- "typestyles": "0.0.0-unstable.de79e3a17eb1",
83
+ "typestyles": "0.0.0-unstable.df708abe489f",
84
84
  "typescript": "^5.4.0",
85
85
  "webpack": "^5.97.1"
86
86
  },
@@ -12,7 +12,7 @@ describe('buildTypestylesForNext route CSS', () => {
12
12
 
13
13
  writeFileSync(
14
14
  join(root, 'styles/typestyles-entry.ts'),
15
- `import { styles } from 'typestyles';\nstyles.class('shared', { margin: '0' });\n`,
15
+ `import { createTypeStyles } from 'typestyles';\nconst { style } = createTypeStyles();\nstyle('shared', { margin: '0' });\n`,
16
16
  );
17
17
  writeFileSync(
18
18
  join(root, 'app/layout.tsx'),
@@ -20,11 +20,11 @@ describe('buildTypestylesForNext route CSS', () => {
20
20
  );
21
21
  writeFileSync(
22
22
  join(root, 'app/page.tsx'),
23
- `import { styles } from 'typestyles';\nstyles.class('home', { color: 'red' });\nexport default function Home() { return null; }\n`,
23
+ `import { createStyles } from 'typestyles';\nconst styles = createStyles();\nstyles.class('home', { color: 'red' });\nexport default function Home() { return null; }\n`,
24
24
  );
25
25
  writeFileSync(
26
26
  join(root, 'app/about/page.tsx'),
27
- `import { styles } from 'typestyles';\nstyles.class('about', { color: 'blue' });\nexport default function About() { return null; }\n`,
27
+ `import { createStyles } from 'typestyles';\nconst styles = createStyles();\nstyles.class('about', { color: 'blue' });\nexport default function About() { return null; }\n`,
28
28
  );
29
29
 
30
30
  try {
@@ -11,7 +11,8 @@ describe('buildTypestylesForNext theme extraction', () => {
11
11
 
12
12
  writeFileSync(
13
13
  join(root, 'styles/typestyles-entry.ts'),
14
- `import { tokens, createTheme } from 'typestyles';
14
+ `import { createTokens, createTheme } from 'typestyles';
15
+ const tokens = createTokens();
15
16
  const color = tokens.create('next-color', { primary: '#0066ff' });
16
17
  createTheme('next-dark', { base: { 'next-color': { primary: '#66aaff' } } });
17
18
  `,
package/src/build.ts CHANGED
@@ -98,10 +98,13 @@ export async function buildTypestylesForNext(
98
98
  const resolvedModules = resolveExtractModulesForNext(root, modules);
99
99
  const enableRouteCss = options.routeCss ?? discoverNextAppRoutesEnabled(root, appDir);
100
100
 
101
+ let extractNonce = 0;
101
102
  const loaders = resolvedModules.map((mod) => {
102
103
  const abs = resolve(root, mod);
103
104
  const href = pathToFileURL(abs).href;
104
- return () => import(href);
105
+ // Cache-bust so a later route-CSS pass can re-import and re-register styles
106
+ // into an isolated sheet (Node ESM caches bare `import(href)` forever).
107
+ return () => import(`${href}?typestyles-extract=${++extractNonce}`);
105
108
  });
106
109
  const css = await collectStylesFromModules(loaders);
107
110
  const outAbs = resolve(root, cssOutFile);