Skip to content

Commit 35d6fa4

Browse files
committed
feat: add vite to bundle
1 parent d4f3e1d commit 35d6fa4

22 files changed

+1978
-4829
lines changed
File renamed without changes.
File renamed without changes.

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ node_modules
44
.DS_Store
55
yarn-debug.log*
66
yarn-error.log*
7-
.idea
7+
.idea
8+
dist
9+
storybook-static
10+
test-results
11+
playwright-report
12+
packages/strapi-icons/src
File renamed without changes.

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"license": "MIT",
77
"private": true,
88
"scripts": {
9-
"analyze:bundle": "lerna run analyze:bundle --stream",
109
"bootstrap": "lerna bootstrap",
1110
"build-storybook": "lerna run build-storybook --stream",
1211
"build": "lerna run build --stream --scope=@strapi/icons && lerna run build --stream --scope=@strapi/design-system",
12+
"clean": "lerna clean",
1313
"generate": "plop",
1414
"lint-staged": "lerna run lint-staged --stream --",
1515
"lint": "lerna run lint --stream",
@@ -27,15 +27,23 @@
2727
},
2828
"devDependencies": {
2929
"@specifyapp/cli": "^0.0.51",
30+
"@vitejs/plugin-react": "^2.2.0",
3031
"chokidar-cli": "^3.0.0",
32+
"cross-env": "^7.0.3",
33+
"eslint": "^7.20.0",
34+
"eslint-config-prettier": "^7.2.0",
35+
"eslint-plugin-mdx": "^1.17.0",
36+
"eslint-plugin-prettier": "^3.3.1",
37+
"eslint-plugin-react": "^7.22.0",
3138
"fs-extra": "^10.0.0",
3239
"husky": "=4",
33-
"jest-styled-components": "^7.1.1",
3440
"lerna": "^4.0.0",
3541
"lint-staged": ">=10",
3642
"plop": "^2.7.4",
43+
"prettier": "^2.7.1",
3744
"rimraf": "^3.0.2",
38-
"url-loader": "^4.1.1"
45+
"tiny-glob": "^0.2.9",
46+
"vite": "^3.2.2"
3947
},
4048
"husky": {
4149
"hooks": {

packages/strapi-design-system/.gitignore

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
node_modules
22
storybook-static
33
.DS_Store
4-
src
4+
src
5+
codemod
6+
.storybook
7+
__mocks__
8+
jest.config.js
9+
playwright.config.js
10+
test-bundler.js
11+
vite.config.js
12+
yarn.lock

packages/strapi-design-system/babel.config.js

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

packages/strapi-design-system/createIndexFiles.js

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

packages/strapi-design-system/package.json

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
{
22
"name": "@strapi/design-system",
33
"version": "1.2.5",
4-
"main": "index.js",
54
"license": "MIT",
5+
"type": "module",
6+
"main": "./dist/index.cjs",
7+
"module": "./dist/index.js",
8+
"exports": {
9+
".": {
10+
"import": "./dist/index.js",
11+
"require": "./dist/index.cjs"
12+
},
13+
"./": "./dist/"
14+
},
15+
"sideEffects": false,
16+
"dependencies": {
17+
"@floating-ui/react-dom": "^1.0.0",
18+
"@internationalized/number": "^3.1.1",
19+
"compute-scroll-into-view": "^1.0.17",
20+
"prop-types": "^15.7.2"
21+
},
622
"devDependencies": {
7-
"@babel/core": "^7.13.10",
8-
"@babel/plugin-transform-runtime": "^7.13.2",
9-
"@babel/preset-env": "^7.13.0",
10-
"@babel/preset-react": "^7.12.13",
11-
"@figspec/react": "^0.1.5",
1223
"@playwright/test": "1.20.0",
1324
"@storybook/addon-actions": "^6.5.13",
1425
"@storybook/addon-essentials": "^6.5.13",
@@ -18,27 +29,17 @@
1829
"@testing-library/react": "^11.2.5",
1930
"axe-playwright": "^1.1.11",
2031
"babel-jest": "^29.2.2",
21-
"babel-loader": "^8.2.2",
22-
"clean-webpack-plugin": "^3.0.0",
23-
"cross-env": "^7.0.3",
24-
"eslint": "^7.20.0",
25-
"eslint-config-prettier": "^7.2.0",
26-
"eslint-plugin-mdx": "^1.17.0",
27-
"eslint-plugin-prettier": "^3.3.1",
28-
"eslint-plugin-react": "^7.22.0",
2932
"intl": "^1.2.5",
3033
"jest": "^29.2.2",
34+
"jest-environment-jsdom": "^29.2.2",
3135
"jest-styled-components": "^7.1.1",
32-
"prettier": "^2.2.1",
3336
"qs": "^6.10.3",
3437
"react": "^17.0.1",
3538
"react-copy-to-clipboard": "^5.0.4",
3639
"react-dom": "^17.0.1",
3740
"react-router-dom": "^5.2.0",
3841
"storybook-dark-mode": "^1.1.2",
39-
"styled-components": "^5.3.6",
40-
"webpack-bundle-analyzer": "^4.4.0",
41-
"webpack-cli": "^4.5.0"
42+
"styled-components": "^5.3.6"
4243
},
4344
"peerDependencies": {
4445
"@strapi/icons": "^1.2.4",
@@ -47,22 +48,16 @@
4748
"react-router-dom": "^5.2.0",
4849
"styled-components": "^5.2.1"
4950
},
50-
"dependencies": {
51-
"@floating-ui/react-dom": "^1.0.0",
52-
"@internationalized/number": "^3.1.1",
53-
"compute-scroll-into-view": "^1.0.17",
54-
"jest-environment-jsdom": "^29.2.2",
55-
"prop-types": "^15.7.2"
51+
"peerDependenciesMeta": {
52+
"react-router-dom": {
53+
"optional": true
54+
}
5655
},
5756
"scripts": {
58-
"analyze:bundle": "cross-env BUNDLE_ANALYZE=1 webpack",
57+
"dev": "vite",
5958
"prebuild": "rimraf dist",
60-
"build": "yarn build:files && cross-env IS_V2=true yarn build:files",
61-
"build:files": "yarn build:dev && yarn build:prod && yarn copy:files && yarn create:index-files",
62-
"build:dev": "cross-env NODE_ENV=development webpack-cli",
63-
"build:prod": "cross-env NODE_ENV=production webpack-cli",
64-
"copy:files": "node ../../tools/copy-files.js",
65-
"create:index-files": "node ./createIndexFiles.js",
59+
"build": "yarn build:prod",
60+
"build:prod": "vite build",
6661
"build-storybook": "build-storybook",
6762
"lint": "eslint . --ext .js,.jsx,.mdx --fix",
6863
"lint-staged": "eslint --fix",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { resolve } from 'path';
2+
import { defineConfig } from 'vite';
3+
import react from '@vitejs/plugin-react';
4+
import glob from 'tiny-glob';
5+
6+
export default glob('./src/**/!(*.spec|*.e2e).{js,svg}').then(async (paths) => {
7+
console.log(paths, resolve(__dirname, './src/index.js'));
8+
return defineConfig({
9+
esbuild: {
10+
loader: 'jsx',
11+
include: /src\/.*\.jsx?$/,
12+
exclude: [],
13+
},
14+
build: {
15+
target: 'es2020',
16+
lib: {
17+
entry: {},
18+
formats: ['cjs', 'es'],
19+
fileName: (format) => {
20+
return `[name].${format === 'es' ? 'js' : format}`;
21+
},
22+
},
23+
rollupOptions: {
24+
input: [resolve(__dirname, './src/index.js'), ...paths.map((path) => `./${path}`)],
25+
// make sure to externalize deps that shouldn't be bundled
26+
// into your library
27+
external: (id) => !id.startsWith('.') && !id.startsWith('/'),
28+
output: {
29+
dir: 'dist',
30+
preserveModules: true,
31+
},
32+
},
33+
},
34+
plugins: [react()],
35+
});
36+
});

packages/strapi-design-system/webpack.config.js

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

0 commit comments

Comments
 (0)