Skip to content

Commit b8230b9

Browse files
committed
chore(package): move packages script to packages packages
1 parent 13d5b06 commit b8230b9

File tree

8 files changed

+159
-86
lines changed

8 files changed

+159
-86
lines changed

package.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,32 @@
3131
},
3232
"scripts": {
3333
"dev": "npm run storybook",
34-
"build": "npm run clean && npm run build:graph && npm run build:react",
35-
"build:graph": "npm run clean:graph && rollup -c --config-package graph && tsc --project packages/graph/tsconfig.json --emitDeclarationOnly && npm run build:graph:umd",
36-
"build:graph:umd": "rollup -c rollup.config.umd.mjs",
37-
"build:react": "npm run clean:react && rollup -c --config-package react && tsc --project packages/react/tsconfig.json --emitDeclarationOnly",
38-
"watch": "rollup -c --watch",
39-
"typecheck": "tsc -b",
40-
"typecheck:watch": "tsc -b --watch",
34+
"build": "npm run build --workspaces --if-present",
35+
"build:graph": "npm run build --workspace=@gravity-ui/graph",
36+
"build:react": "npm run build --workspace=@gravity-ui/graph-react",
37+
"watch": "npm run watch --workspace=@gravity-ui/graph",
38+
"watch:graph": "npm run watch --workspace=@gravity-ui/graph",
39+
"watch:react": "npm run watch --workspace=@gravity-ui/graph-react",
40+
"clean": "npm run clean --workspaces --if-present",
41+
"clean:graph": "npm run clean --workspace=@gravity-ui/graph",
42+
"clean:react": "npm run clean --workspace=@gravity-ui/graph-react",
43+
"lint": "npm run lint --workspaces --if-present",
44+
"lint:graph": "npm run lint --workspace=@gravity-ui/graph",
45+
"lint:react": "npm run lint --workspace=@gravity-ui/graph-react",
46+
"lint:stories": "npm run lint --workspace=@gravity-ui/graph-stories",
47+
"lint:fix": "npm run lint:fix --workspaces --if-present",
48+
"typecheck": "npm run typecheck --workspaces --if-present",
49+
"typecheck:graph": "npm run typecheck --workspace=@gravity-ui/graph",
50+
"typecheck:react": "npm run typecheck --workspace=@gravity-ui/graph-react",
51+
"typecheck:stories": "npm run typecheck --workspace=@gravity-ui/graph-stories",
4152
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
53+
"test:graph": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --selectProjects=graph",
54+
"test:react": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --selectProjects=react",
4255
"test:watch": "npm run test -- --watch",
4356
"test:update": "npm run test -- --updateSnapshot",
44-
"lint": "eslint \"packages/*/src/**/*.{js,jsx,ts,tsx}\"",
45-
"lint:fix": "npm run lint -- --fix",
4657
"storybook": "storybook dev -p 6006",
4758
"build-storybook": "storybook build",
4859
"ci:storybook:build": "npm run build-storybook",
49-
"clean": "rm -rf packages/*/dist packages/*/build",
50-
"clean:graph": "rm -rf packages/graph/dist packages/graph/build",
51-
"clean:react": "rm -rf packages/react/dist packages/react/build",
5260
"size": "npm run build && size-limit"
5361
},
5462
"size-limit": [

packages/graph/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@
5353
"files": [
5454
"dist"
5555
],
56+
"scripts": {
57+
"build": "npm run clean && npm run build:esm && npm run build:types && npm run build:umd",
58+
"build:esm": "rollup -c rollup.config.mjs",
59+
"build:umd": "rollup -c rollup.config.umd.mjs",
60+
"build:types": "tsc --emitDeclarationOnly",
61+
"watch": "rollup -c rollup.config.mjs --watch",
62+
"clean": "rm -rf dist",
63+
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
64+
"lint:fix": "npm run lint -- --fix",
65+
"typecheck": "tsc -b"
66+
},
5667
"dependencies": {
5768
"@preact/signals-core": "^1.5.1",
5869
"intersects": "^2.7.2",

packages/graph/rollup.config.mjs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import commonjs from "@rollup/plugin-commonjs";
2+
import resolve from "@rollup/plugin-node-resolve";
3+
import typescript from "@rollup/plugin-typescript";
4+
import copy from "rollup-plugin-copy";
5+
import postcss from "rollup-plugin-postcss";
6+
7+
export default {
8+
input: {
9+
index: "src/index.ts",
10+
utils: "src/utils.ts",
11+
},
12+
output: {
13+
dir: "dist",
14+
format: "esm",
15+
preserveModules: true,
16+
preserveModulesRoot: "src",
17+
sourcemap: true,
18+
},
19+
external: (id) => {
20+
return /^lodash/.test(id) || /^@preact/.test(id) || ["intersects", "rbush", "style-observer"].includes(id);
21+
},
22+
plugins: [
23+
resolve({
24+
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
25+
}),
26+
typescript({
27+
tsconfig: "./tsconfig.json",
28+
declaration: false,
29+
}),
30+
commonjs(),
31+
postcss({
32+
extract: false,
33+
inject: false,
34+
modules: false,
35+
}),
36+
copy({
37+
targets: [
38+
{
39+
src: "src/**/*.css",
40+
dest: "dist",
41+
rename: (name, extension, fullPath) => {
42+
// Remove the 'src/' prefix from the path
43+
const relativePath = fullPath.replace(/^src\//, "");
44+
return relativePath;
45+
},
46+
},
47+
],
48+
}),
49+
],
50+
watch: {
51+
include: "src/**",
52+
exclude: "node_modules/**",
53+
},
54+
};

rollup.config.umd.mjs renamed to packages/graph/rollup.config.umd.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import typescript from "@rollup/plugin-typescript";
55
import postcss from "rollup-plugin-postcss";
66

77
const createConfig = (minify = false) => ({
8-
input: "packages/graph/src/index.umd.ts",
8+
input: "src/index.umd.ts",
99
output: {
10-
file: minify ? "packages/graph/dist/graph.umd.min.js" : "packages/graph/dist/graph.umd.js",
10+
file: minify ? "dist/graph.umd.min.js" : "dist/graph.umd.js",
1111
format: "umd",
1212
name: "GravityGraph",
1313
sourcemap: true,
@@ -18,7 +18,7 @@ const createConfig = (minify = false) => ({
1818
browser: true,
1919
}),
2020
typescript({
21-
tsconfig: "packages/graph/tsconfig.json",
21+
tsconfig: "./tsconfig.json",
2222
declaration: false,
2323
}),
2424
commonjs(),
@@ -37,7 +37,6 @@ const createConfig = (minify = false) => ({
3737
ecma: 2015,
3838
},
3939
format: {
40-
// Нужно уточнить, нужно ли Добавить copyright лицензию
4140
comments: false,
4241
},
4342
}),

packages/react/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
"files": [
3636
"dist"
3737
],
38+
"scripts": {
39+
"build": "npm run clean && npm run build:esm && npm run build:types",
40+
"build:esm": "rollup -c rollup.config.mjs",
41+
"build:types": "tsc --emitDeclarationOnly",
42+
"watch": "rollup -c rollup.config.mjs --watch",
43+
"clean": "rm -rf dist",
44+
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
45+
"lint:fix": "npm run lint -- --fix",
46+
"typecheck": "tsc -b"
47+
},
3848
"devDependencies": {
3949
"lodash": "^4.17.21"
4050
},

packages/react/rollup.config.mjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import commonjs from "@rollup/plugin-commonjs";
2+
import resolve from "@rollup/plugin-node-resolve";
3+
import typescript from "@rollup/plugin-typescript";
4+
import copy from "rollup-plugin-copy";
5+
import postcss from "rollup-plugin-postcss";
6+
7+
export default {
8+
input: "src/index.ts",
9+
output: {
10+
dir: "dist",
11+
format: "esm",
12+
preserveModules: true,
13+
preserveModulesRoot: "src",
14+
sourcemap: true,
15+
},
16+
external: (id) => {
17+
return (
18+
/^react/.test(id) ||
19+
/^@gravity-ui\/graph/.test(id) ||
20+
/^@preact/.test(id) ||
21+
["elkjs", "lodash", "intersects"].includes(id)
22+
);
23+
},
24+
plugins: [
25+
resolve({
26+
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
27+
}),
28+
typescript({
29+
tsconfig: "./tsconfig.json",
30+
declaration: false,
31+
}),
32+
commonjs(),
33+
postcss({
34+
extract: false,
35+
inject: false,
36+
modules: false,
37+
}),
38+
copy({
39+
targets: [
40+
{
41+
src: "src/**/*.css",
42+
dest: "dist",
43+
rename: (name, extension, fullPath) => {
44+
// Remove the 'src/' prefix from the path
45+
const relativePath = fullPath.replace(/^src\//, "");
46+
return relativePath;
47+
},
48+
},
49+
],
50+
}),
51+
],
52+
watch: {
53+
include: "src/**",
54+
exclude: "node_modules/**",
55+
},
56+
};

packages/stories/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
"react": "^18.2.0",
1818
"react-dom": "^18.2.0"
1919
},
20+
"scripts": {
21+
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
22+
"lint:fix": "npm run lint -- --fix",
23+
"typecheck": "tsc -b"
24+
},
2025
"devDependencies": {
2126
"@storybook/react-webpack5": "^9.1.2",
2227
"@types/lodash": "^4.17.13"

rollup.config.mjs

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

0 commit comments

Comments
 (0)