Skip to content

Commit 9e68153

Browse files
committed
chore!: remove direct imports & publish types (#1485)
1 parent 6e94ce2 commit 9e68153

28 files changed

+1211
-745
lines changed

.changeset/quiet-roses-rule.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': major
3+
---
4+
5+
chore!: remove direct imports. Users should import everything from the root of the project instead.

BREAKING_CHANGES.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Breaking Changes Migration guide
2+
3+
## What is this?
4+
5+
This is a living document of all the breaking changes in v2 of the design system. If you've added a breaking change, you'll be expected to update this document accordingly.
6+
7+
## Changelog
8+
9+
### Remove direct imports
10+
11+
Users can no longer `import { Combobox } from '@strapi/design-system/Combobox'`, instead they should import _all_ things from the root of the project.
12+
13+
### Published types
14+
15+
`@strapi/design-system` now comes with typescript definitions. This means you can remove any overrides you may have. They've been tested against the CMS, if you feel there are mistakes, please open a PR to fix them.

docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"@storybook/react-vite": "^7.5.3",
2525
"@storybook/theming": "7.5.3",
2626
"eslint-plugin-mdx": "^2.2.0",
27-
"storybook": "^7.5.3"
27+
"storybook": "^7.5.3",
28+
"vite": "^5.0.2"
2829
},
2930
"scripts": {
3031
"build": "storybook build",

docs/styled.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'styled-components';
2-
import type { StrapiTheme } from '@strapi/design-system';
32

43
declare module 'styled-components' {
54
/**

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,24 @@
2828
"prerelease:exit": "changeset pre exit",
2929
"release:add": "changeset add",
3030
"release:publish": "turbo run build lint test:ts test && changeset publish",
31-
"release:version": "changeset version && yarn"
31+
"release:version": "changeset version && yarn",
32+
"watch": "turbo run watch"
3233
},
3334
"devDependencies": {
3435
"@changesets/changelog-git": "0.2.0",
3536
"@changesets/cli": "2.26.2",
3637
"@commitlint/cli": "18.4.3",
3738
"@commitlint/config-conventional": "18.4.3",
3839
"@juggle/resize-observer": "^3.4.0",
39-
"@rollup/plugin-typescript": "^11.1.5",
4040
"@strapi/eslint-config": "^0.2.0",
41+
"@strapi/pack-up": "4.15.5",
4142
"@swc/core": "^1.3.100",
4243
"@swc/jest": "^0.2.29",
4344
"@testing-library/jest-dom": "6.1.5",
4445
"@testing-library/react": "14.1.2",
4546
"@testing-library/user-event": "^14.5.1",
46-
"@tsconfig/node16": "^16.1.1",
4747
"@types/jest": "^29.5.10",
48+
"@types/node": "20.10.0",
4849
"@types/react": "18.2.41",
4950
"@types/react-dom": "18.2.17",
5051
"@typescript-eslint/eslint-plugin": "^6.13.2",
@@ -72,11 +73,8 @@
7273
"react": "^18.2.0",
7374
"react-dom": "^18.2.0",
7475
"rimraf": "^5.0.5",
75-
"tiny-glob": "^0.2.9",
7676
"turbo": "1.10.16",
77-
"typescript": "^5.3.2",
78-
"vite": "^5.0.4",
79-
"vite-plugin-dts": "^3.6.4"
77+
"typescript": "^5.3.2"
8078
},
8179
"packageManager": "[email protected]",
8280
"engines": {

packages/primitives/.eslintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"root": true,
33
"extends": ["@strapi/eslint-config/front/typescript"],
44
"parserOptions": {
5-
"project": ["./tsconfig.eslint.json"]
5+
"project": ["./tsconfig.json"]
66
},
77
"settings": {
88
"import/resolver": {
99
"typescript": {
10-
"project": "./tsconfig.eslint.json"
10+
"project": "./tsconfig.json"
1111
}
1212
}
1313
},

packages/primitives/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
"version": "1.13.2",
44
"license": "MIT",
55
"sideEffects": false,
6-
"main": "./dist/ui-primitives.js",
7-
"module": "./dist/ui-primitives.mjs",
6+
"source": "./src/index.ts",
7+
"main": "./dist/index.js",
8+
"module": "./dist/index.mjs",
89
"types": "./dist/index.d.ts",
910
"files": [
1011
"dist"
1112
],
1213
"scripts": {
13-
"prebuild": "rimraf dist",
14-
"build": "yarn build:prod",
15-
"build:prod": "vite build",
14+
"build": "pack-up build",
1615
"clean": "rimraf dist node_modules",
1716
"lint": "eslint . --ext .js,.jsx,.tsx,.ts",
1817
"format": "yarn lint --fix",
1918
"test": "jest -c jest.config.mjs",
2019
"test:ts": "tsc --noEmit",
21-
"test:watch": "jest -c jest.config.mjs --watchAll"
20+
"test:watch": "jest -c jest.config.mjs --watchAll",
21+
"watch": "pack-up watch"
2222
},
2323
"dependencies": {
2424
"@radix-ui/number": "^1.0.1",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist"
5+
},
6+
"exclude": ["**/*.test.tsx", "**/*.test.ts"],
7+
"include": ["src"]
8+
}

packages/primitives/tsconfig.eslint.json

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

packages/primitives/tsconfig.json

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,20 @@
22
"compilerOptions": {
33
"target": "ESNext",
44
"module": "ESNext",
5-
"moduleResolution": "node",
5+
"moduleResolution": "Bundler",
66
"useDefineForClassFields": true,
77
"lib": ["DOM", "DOM.Iterable", "ESNext"],
88
"allowJs": false,
99
"skipLibCheck": true,
10-
"esModuleInterop": false,
10+
"esModuleInterop": true,
1111
"allowSyntheticDefaultImports": true,
1212
"strict": true,
1313
"forceConsistentCasingInFileNames": true,
1414
"resolveJsonModule": true,
15-
"isolatedModules": true,
1615
"noEmit": true,
17-
"outDir": "dist",
18-
"declaration": true,
16+
"noImplicitAny": true,
1917
"jsx": "react-jsx",
20-
"types": ["vite/client"]
18+
"types": ["jest", "@testing-library/jest-dom"]
2119
},
22-
"exclude": ["**/*.test.tsx", "**/*.test.ts"],
23-
"include": ["src"],
24-
"references": [
25-
{
26-
"path": "./tsconfig.node.json"
27-
}
28-
]
20+
"include": ["src"]
2921
}

packages/primitives/tsconfig.node.json

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

packages/primitives/vite.config.ts

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

packages/strapi-design-system/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"parser": "@typescript-eslint/parser",
55
"plugins": ["@typescript-eslint", "prettier"],
66
"parserOptions": {
7-
"project": ["./tsconfig.eslint.json"]
7+
"project": ["./tsconfig.json"]
88
},
99
"rules": {
1010
"consistent-return": "off",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
declare module '*.png' {
2+
const value: any;
3+
export default value;
4+
}
5+
6+
declare module '*.svg' {
7+
const value: any;
8+
export default value;
9+
}

packages/strapi-design-system/package.json

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,10 @@
33
"version": "1.13.2",
44
"license": "MIT",
55
"sideEffects": false,
6+
"source": "./src/index.ts",
67
"main": "./dist/index.js",
78
"module": "./dist/index.mjs",
89
"types": "./dist/index.d.ts",
9-
"exports": {
10-
"./package.json": "./package.json",
11-
".": {
12-
"types": "./dist/index.d.ts",
13-
"import": "./dist/index.mjs",
14-
"require": "./dist/index.js",
15-
"default": "./dist/index.js"
16-
},
17-
"./v2": {
18-
"types": "./dist/v2/index.d.ts",
19-
"import": "./dist/v2/index.mjs",
20-
"require": "./dist/v2/index.js",
21-
"default": "./dist/v2/index.js"
22-
},
23-
"./*": "./dist/*"
24-
},
2510
"files": [
2611
"dist"
2712
],
@@ -37,7 +22,6 @@
3722
"@uiw/react-codemirror": "^4.21.21",
3823
"aria-hidden": "^1.2.3",
3924
"compute-scroll-into-view": "^3.1.0",
40-
"prop-types": "^15.8.1",
4125
"react-remove-scroll": "^2.5.7"
4226
},
4327
"devDependencies": {
@@ -58,8 +42,7 @@
5842
"styled-components": "^5.2.1"
5943
},
6044
"scripts": {
61-
"build": "yarn clean && yarn build:prod",
62-
"build:prod": "vite build",
45+
"build": "pack-up build",
6346
"clean": "rimraf dist node_modules",
6447
"generate:types": "tsc --noEmit false --declaration --emitDeclarationOnly --declarationDir dist",
6548
"lint": "eslint . --ext .tsx,.ts",
@@ -70,7 +53,8 @@
7053
"test:e2e": "playwright test",
7154
"test:e2e:ci": "cross-env CI=true playwright test",
7255
"test:e2e:watch": "chokidar '**/__tests__/*.e2e.js' -c 'npm run test:e2e -- --retries=0 {path}'",
73-
"test:e2e:debug": "cross-env PWDEBUG=1 playwright test"
56+
"test:e2e:debug": "cross-env PWDEBUG=1 playwright test",
57+
"watch": "pack-up watch"
7458
},
7559
"gitHead": "c74900b0ee3525510d266dc83c9743cb24dafced"
7660
}

packages/strapi-design-system/src/Tooltip/hooks/useTooltipHandlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useRef, useState, useEffect } from 'react';
22

33
export const useTooltipHandlers = (delay: number) => {
44
const [visible, setVisible] = useState(false);
5-
const timerRef = useRef<number | null>(null);
5+
const timerRef = useRef<NodeJS.Timeout | null>(null);
66

77
const clearTimer = () => {
88
if (typeof timerRef.current === 'number') {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist"
5+
},
6+
"exclude": ["**/*.test.tsx", "**/*.test.ts", "**/__tests__/**/*"],
7+
"include": ["src", "styled.d.ts", "module.d.ts"]
8+
}

packages/strapi-design-system/tsconfig.eslint.json

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

packages/strapi-design-system/tsconfig.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@
1515
"isolatedModules": true,
1616
"noEmit": true,
1717
"jsx": "react-jsx",
18-
"types": ["vite/client", "jest", "@testing-library/jest-dom"],
18+
"types": ["node", "jest", "@testing-library/jest-dom"],
1919
"baseUrl": ".",
2020
"paths": {
2121
"@test/*": ["./test/*"]
2222
}
2323
},
24-
"exclude": ["**/*.test.tsx", "**/*.test.ts"],
25-
"include": ["src", "styled.d.ts"],
26-
"references": [
27-
{
28-
"path": "./tsconfig.node.json"
29-
}
30-
]
24+
"include": ["src", "test", "styled.d.ts", "module.d.ts", "*.config.ts", "*.config.mjs"]
3125
}

packages/strapi-design-system/tsconfig.node.json

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

packages/strapi-design-system/vite.config.ts

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

0 commit comments

Comments
 (0)