Skip to content

Commit dfc90af

Browse files
authored
fix: use tsdown (#3)
1 parent c2cfebe commit dfc90af

File tree

11 files changed

+503
-163
lines changed

11 files changed

+503
-163
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"dependencies": {
1111
"@types/react": "19.1.4",
12-
"@types/react-dom": "19.1.5"
12+
"@types/react-dom": "19.1.5",
13+
"typescript": "5.8.3"
1314
},
1415
"packageManager": "[email protected]",
1516
"engines": {

packages/css-in-js/.npmignore

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/css-in-js/package.json

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
{
22
"name": "@sanity/css-in-js",
33
"version": "6.1.18-2",
4-
"description": "CSS for the <Component> Age. Style components your way with speed, strong typing, and flexibility.",
4+
"description": "A fork of styled-components that supports React 19 streaming ssr without ServerStyleSheet or sheet.collectStyles techniques",
55
"publishConfig": {
66
"access": "public"
77
},
8-
"types": "dist/index.d.ts",
9-
"main": "dist/styled-components.cjs.js",
10-
"module": "./dist/styled-components.esm.js",
11-
"browser": {
12-
"./dist/styled-components.cjs.js": "./dist/styled-components.browser.cjs.js",
13-
"./dist/styled-components.esm.js": "./dist/styled-components.browser.esm.js"
8+
"types": "dist/default/index.d.ts",
9+
"type": "module",
10+
"exports": {
11+
".": {
12+
"node": "./dist/node/index.js",
13+
"browser": "./dist/browser/index.js",
14+
"default": "./dist/default/index.js"
15+
},
16+
"./package.json": "./package.json"
1417
},
1518
"sideEffects": false,
1619
"scripts": {
17-
"generateErrors": "node scripts/generateErrorMap.js",
18-
"prebuild": "rimraf dist && pnpm generateErrors",
19-
"build": "rollup -c",
20+
"generateErrors": "node scripts/generateErrorMap.cjs",
21+
"prebuild": "pnpm generateErrors",
22+
"build": "tsdown",
2023
"pretest": "pnpm generateErrors",
2124
"test": "jest -c jest.config.main.js",
2225
"prepare": "pnpm build"
@@ -27,8 +30,6 @@
2730
"directory": "packages/css-in-js"
2831
},
2932
"files": [
30-
"LICENSE",
31-
"README.md",
3233
"dist"
3334
],
3435
"keywords": [
@@ -56,8 +57,8 @@
5657
"tslib": "2.6.2"
5758
},
5859
"peerDependencies": {
59-
"react": ">= 18.3.0",
60-
"react-dom": ">= 18.3.0"
60+
"react": "^19.1",
61+
"react-dom": "^19.1"
6162
},
6263
"devDependencies": {
6364
"@babel/core": "7.24.5",
@@ -106,18 +107,11 @@
106107
"rollup-plugin-sourcemaps": "0.6.3",
107108
"rollup-plugin-terser": "7.0.2",
108109
"stylis-plugin-rtl": "2.1.1",
110+
"tsdown": "0.11.9",
109111
"ts-toolbelt": "9.6.0",
110-
"typescript": "5.4.5"
111-
},
112-
"bundlewatch": {
113-
"files": [
114-
{
115-
"path": "./dist/styled-components.min.js",
116-
"maxSize": "11.5kB"
117-
}
118-
]
112+
"typescript": "5.8.3"
119113
},
120114
"engines": {
121-
"node": ">= 16"
115+
"node": ">= 22"
122116
}
123117
}

packages/css-in-js/src/base.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ if (
5353

5454
/* Export everything */
5555
export * from './secretInternals';
56-
export { Attrs, DefaultTheme, ShouldForwardProp } from './types';
56+
export type { Attrs, DefaultTheme, ShouldForwardProp } from './types';
5757
export {
58-
IStyleSheetContext,
59-
IStyleSheetManager,
60-
IStylisContext,
58+
type IStyleSheetContext,
59+
type IStyleSheetManager,
60+
type IStylisContext,
6161
ServerStyleSheet,
6262
StyleSheetConsumer,
6363
StyleSheetContext,

packages/css-in-js/src/constructors/styled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ domElements.forEach(domElement => {
2424
});
2525

2626
export default styled;
27-
export { StyledInstance };
27+
export type { StyledInstance };
2828

2929
/**
3030
* This is the type of the `styled` HOC.

packages/css-in-js/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled, { LibraryStyled, Styled, StyledInstance } from './constructors/styled';
22

33
export * from './base';
4-
export {
4+
export type {
55
CSSKeyframes,
66
CSSObject,
77
CSSProp,
@@ -26,4 +26,4 @@ export {
2626
SupportedHTMLElements,
2727
WebTarget,
2828
} from './types';
29-
export { LibraryStyled, Styled, StyledInstance, styled as default, styled };
29+
export { type LibraryStyled, type Styled, type StyledInstance, styled };

packages/css-in-js/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { DefaultTheme } from './models/ThemeProvider';
55
import createWarnTooManyClasses from './utils/createWarnTooManyClasses';
66
import type { SupportedHTMLElements } from './utils/domElements';
77

8-
export { CSS, DefaultTheme, SupportedHTMLElements };
8+
export { CSS, type DefaultTheme, SupportedHTMLElements };
99

1010
export interface ExoticComponentWithDisplayName<P extends object = {}>
1111
extends React.ExoticComponent<P> {

packages/css-in-js/tsconfig.json

Lines changed: 32 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,39 @@
22
"include": ["src"],
33
"exclude": ["dist", ".rollup.cache", "src/test/test.d.ts"],
44
"compilerOptions": {
5-
"tsBuildInfoFile": "local.tsbuildinfo",
65
"outDir": "dist",
7-
/* Visit https://aka.ms/tsconfig.json to read more about this file */
6+
"declaration": true,
7+
"emitDeclarationOnly": true,
88

9-
/* Basic Options */
10-
"incremental": true /* Enable incremental compilation */,
11-
"target": "ES5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
12-
"module": "ESNext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
13-
"lib": ["ES2021", "DOM"] /* Specify library files to be included in the compilation. */,
14-
// "allowJs": true, /* Allow javascript files to be compiled. */
15-
// "checkJs": true, /* Report errors in .js files. */
16-
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
17-
"declaration": true /* Generates corresponding '.d.ts' file. */,
18-
// "declarationDir": ".",
19-
// "declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
20-
// "sourceMap": true, /* Generates corresponding '.map' file. */
21-
// "outFile": "./", /* Concatenate and emit output to single file. */
22-
// "outDir": "./", /* Redirect output structure to the directory. */
23-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
24-
// "composite": true, /* Enable project compilation */
25-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
26-
// "removeComments": true, /* Do not emit comments to output. */
27-
"noEmit": true /* Do not emit outputs. */,
28-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
29-
"downlevelIteration": false /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */,
30-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
31-
32-
/* Strict Type-Checking Options */
33-
"strict": true /* Enable all strict type-checking options. */,
34-
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
35-
// "strictNullChecks": true, /* Enable strict null checks. */
36-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
37-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
38-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
39-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
40-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
41-
42-
/* Additional Checks */
43-
// "noUnusedLocals": true, /* Report errors on unused locals. */
44-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
45-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
46-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
47-
"exactOptionalPropertyTypes": true /* Interpret optional property types as written, rather than adding 'undefined'. */,
48-
49-
/* Module Resolution Options */
50-
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
51-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
52-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
53-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
54-
// "typeRoots": [], /* List of folders to include type definitions from. */
55-
// "types": [] /* Type declaration files to be included in compilation. */,
56-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
57-
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
58-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
59-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
60-
61-
/* Source Map Options */
62-
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
63-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
64-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
65-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
66-
67-
/* Experimental Options */
68-
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
69-
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
70-
71-
/* Advanced Options */
72-
"skipLibCheck": true /* Skip type checking of declaration files. */,
73-
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
9+
"target": "ESNext",
10+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
11+
"jsx": "react-jsx",
12+
"module": "Preserve",
13+
"moduleDetection": "force",
14+
"moduleResolution": "Bundler",
15+
"allowImportingTsExtensions": true,
16+
"resolveJsonModule": true,
17+
"allowJs": true,
18+
"noEmit": true,
19+
"allowSyntheticDefaultImports": true,
20+
"esModuleInterop": true,
21+
"forceConsistentCasingInFileNames": true,
22+
"skipLibCheck": true,
23+
"erasableSyntaxOnly": true,
24+
"checkJs": true,
25+
"isolatedModules": true,
26+
// "verbatimModuleSyntax": true,
27+
"strict": true,
28+
"noUnusedLocals": true,
29+
"noUnusedParameters": true,
30+
"noFallthroughCasesInSwitch": true,
31+
"strictNullChecks": true,
32+
"strictFunctionTypes": true,
33+
"strictPropertyInitialization": true,
34+
"alwaysStrict": true,
35+
"noImplicitAny": true,
36+
"noImplicitThis": true,
37+
"noImplicitReturns": true,
38+
"noImplicitOverride": true,
7439
}
7540
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { defineConfig, type UserConfig } from 'tsdown/config';
2+
import pkg from './package.json' with { type: 'json' };
3+
4+
const base = {
5+
entry: 'src/index.ts',
6+
sourcemap: true,
7+
dts: true,
8+
outputOptions: { format: 'esm' },
9+
define: { __VERSION__: JSON.stringify(pkg.version) },
10+
} satisfies UserConfig;
11+
12+
export default [
13+
defineConfig({
14+
...base,
15+
define: { ...base.define, __SERVER__: JSON.stringify(true) },
16+
platform: 'node',
17+
outDir: 'dist/node',
18+
}),
19+
defineConfig({
20+
...base,
21+
define: { ...base.define, __SERVER__: JSON.stringify(false) },
22+
platform: 'browser',
23+
outDir: 'dist/browser',
24+
}),
25+
defineConfig({
26+
...base,
27+
define: { ...base.define, __SERVER__: JSON.stringify(false) },
28+
platform: 'neutral',
29+
outDir: 'dist/default',
30+
}),
31+
];

0 commit comments

Comments
 (0)