Skip to content

Commit

Permalink
fix(build): fixes build so can be more easily used
Browse files Browse the repository at this point in the history
Removes tsup and uses esbuild directly - tsup probably only suitable for node modules

fixes #78
  • Loading branch information
stuarthendren committed Oct 10, 2022
1 parent 2a1889f commit e699702
Show file tree
Hide file tree
Showing 13 changed files with 364 additions and 900 deletions.
19 changes: 0 additions & 19 deletions apps/docs/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,6 @@ module.exports = {
},
},
framework: '@storybook/react',
core: {
builder: 'webpack4',
},
features: {
postcss: false,
},

webpackFinal: async (config, { configType }) => {
config.resolve?.extensions?.push('*', '.mjs', '.js', '.json')

if(config.module){
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
})
}
return config;
},

previewHead: (head) => (`
${head}
Expand Down
4 changes: 0 additions & 4 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"dependencies": {
"@committed/components": "^8.1.3",
"@committed/components-graph": "*",
"@committed/components-graph-react": "*",
"@committed/graph": "*",
"@committed/graph-json": "*",
"@committed/graph-rdf": "*",
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
Expand Down
1,009 changes: 247 additions & 762 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
"@typescript-eslint/parser": "^5.38.1",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"esbuild": "^0.15.10",
"esbuild-node-externals": "^1.5.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.7.1",
Expand All @@ -100,7 +102,6 @@
"storybook-dark-mode": "^1.0.8",
"ts-jest": "^29.0.3",
"tslib": "^2.0.3",
"tsup": "^6.2.3",
"turbo": "^1.5.4",
"typescript": "4.7.4"
},
Expand Down
33 changes: 12 additions & 21 deletions packages/all/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"author": "Committed",
"license": "MIT",
"private": false,
"main": "./dist/index.js",
"module": "./dist/esm/index.js",
"typings": "./dist/index.d.ts",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"publishConfig": {
"access": "public",
Expand All @@ -20,12 +20,14 @@
"node": ">=10"
},
"peerDependencies": {
"@committed/components": ">= 5.0.0",
"@committed/components": ">= 8.0.0",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0"
},
"devDependencies": {
"@committed/config": "*"
"@committed/config": "*",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"dependencies": {
"@committed/graph": "*",
Expand All @@ -35,26 +37,15 @@
},
"scripts": {
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"build": "tsup --legacy-output && tsc",
"build:clean": "rm -rf dist",
"build:ts": "tsc --project tsconfig.json",
"build:js": "node ../../node_modules/@committed/config/esbuild/build.mjs",
"build": "npm run build:clean && npm run build:ts && npm run build:js",
"lint": "tsc && eslint './src/**/*.{ts,tsx}'",
"test": "jest --passWithNoTests",
"test:ci": "jest --coverage --passWithNoTests",
"test:watch": "jest --watch --passWithNoTests",
"precommit": "lint-staged",
"dev": "tsup --watch"
},
"tsup": {
"clean": true,
"entry": [
"src/index.ts"
],
"format": [
"cjs",
"esm"
],
"target": "es2020",
"minify": true,
"sourcemap": true
"precommit": "lint-staged"
},
"repository": {
"type": "git",
Expand Down
27 changes: 27 additions & 0 deletions packages/config/esbuild/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { build } from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'

const entryFile = 'src/index.ts'
const outFolder = 'dist'

const shared = {
bundle: true,
entryPoints: [entryFile],
logLevel: 'info',
minify: true,
sourcemap: true,
target: ['esnext', 'node16'],
plugins: [nodeExternalsPlugin()],
}

build({
...shared,
format: 'esm',
outfile: `${outFolder}/index.esm.js`,
})

build({
...shared,
format: 'cjs',
outfile: `${outFolder}/index.cjs.js`,
})
31 changes: 11 additions & 20 deletions packages/graph-json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"author": "Committed",
"private": false,
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/index.d.ts",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"files": [
"dist"
Expand All @@ -32,34 +32,25 @@
},
"scripts": {
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"build": "tsup --legacy-output && tsc --project tsconfig.build.json",
"build:clean": "rm -rf dist",
"build:ts": "tsc --project tsconfig.build.json",
"build:js": "node ../../node_modules/@committed/config/esbuild/build.mjs",
"build": "npm run build:clean && npm run build:ts && npm run build:js",
"lint": "tsc && eslint './src/**/*.{ts,tsx}'",
"dev": "tsup --legacy-output --watch",
"fix": "TIMING=1 eslint src/**/*.ts* --fix",
"test": "jest",
"test:ci": "jest --coverage",
"test:watch": "jest --watchAll",
"precommit": "lint-staged"
},
"tsup": {
"clean": true,
"entry": [
"src/index.ts"
],
"format": [
"cjs",
"esm"
],
"target": "es2020",
"minify": true,
"sourcemap": true,
"tsconfig": "./tsconfig.build.json"
},
"devDependencies": {
"@committed/graph": "*",
"@committed/config": "*"
},
"peerDependencies": {
"@committed/graph": "*"
},
"dependencies": {
"@committed/graph": "*",
"uuid": "^8.3.2"
}
}
31 changes: 11 additions & 20 deletions packages/graph-rdf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"author": "Committed",
"private": false,
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/index.d.ts",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"files": [
"dist"
Expand All @@ -32,34 +32,25 @@
},
"scripts": {
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"build": "tsup --legacy-output && tsc --project tsconfig.build.json",
"build:clean": "rm -rf dist",
"build:ts": "tsc --project tsconfig.build.json",
"build:js": "node ../../node_modules/@committed/config/esbuild/build.mjs",
"build": "npm run build:clean && npm run build:ts && npm run build:js",
"lint": "tsc && eslint './src/**/*.{ts,tsx}'",
"test": "jest",
"test:ci": "jest --coverage",
"test:watch": "jest --watchAll",
"precommit": "lint-staged",
"dev": "tsup --legacy-output --watch",
"fix": "TIMING=1 eslint src/**/*.ts* --fix"
},
"tsup": {
"clean": true,
"entry": [
"src/index.ts"
],
"format": [
"cjs",
"esm"
],
"target": "es2020",
"minify": true,
"sourcemap": true,
"tsconfig": "./tsconfig.build.json"
},
"devDependencies": {
"@committed/graph": "*",
"@committed/config": "*"
},
"peerDependencies": {
"@committed/graph": "*"
},
"dependencies": {
"@committed/graph": "*",
"n3": "^1.11.1",
"rdf-literal": "^1.3.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/graph-rdf/src/utils/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const prefixedId =
const match = Object.keys(prefixes).find((prefix) => id.startsWith(prefix))
if (match !== undefined) {
const prefix = prefixes[match]
return `${prefix}:${id.substr(match.length)}`
return `${prefix}:${id.substring(match.length)}`
}
return id
}
Expand All @@ -23,7 +23,7 @@ export const fragmentId = (id: string): string => {
const url = new URL(id)
const hash = url.hash
if (hash) {
return hash.substr(1)
return hash.substring(1)
}
const path = url.pathname
return path.substring(path.lastIndexOf('/') + 1)
Expand Down
26 changes: 7 additions & 19 deletions packages/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"author": "Committed",
"private": false,
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/index.d.ts",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"files": [
"dist"
Expand All @@ -32,29 +32,17 @@
},
"scripts": {
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"build": "tsup --legacy-output && tsc --project tsconfig.build.json",
"build:clean": "rm -rf dist",
"build:ts": "tsc --project tsconfig.build.json",
"build:js": "node ../../node_modules/@committed/config/esbuild/build.mjs",
"build": "npm run build:clean && npm run build:ts && npm run build:js",
"lint": "tsc && eslint './src/**/*.{ts,tsx}'",
"test": "jest",
"test:ci": "jest --coverage",
"test:watch": "jest --watchAll",
"precommit": "lint-staged",
"dev": "tsup --legacy-output --watch",
"fix": "TIMING=1 eslint src/**/*.ts* --fix"
},
"tsup": {
"clean": true,
"entry": [
"src/index.ts"
],
"format": [
"cjs",
"esm"
],
"target": "es2020",
"minify": true,
"sourcemap": true,
"tsconfig": "./tsconfig.build.json"
},
"devDependencies": {
"@committed/config": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/graph/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"rootDir": "src",
"outDir": "dist"
},
"include": ["src", "../graph-json/src/fromJsonGraph.test.ts"]
"include": ["src"]
}
33 changes: 12 additions & 21 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"author": "Committed",
"private": false,
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/index.d.ts",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"files": [
"dist"
Expand All @@ -32,39 +32,30 @@
},
"scripts": {
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"build": "tsup --legacy-output && tsc --project tsconfig.build.json",
"build:clean": "rm -rf dist",
"build:ts": "tsc --project tsconfig.build.json",
"build:js": "node ../../node_modules/@committed/config/esbuild/build.mjs",
"build": "npm run build:clean && npm run build:ts && npm run build:js",
"lint": "tsc && eslint './src/**/*.{ts,tsx}'",
"test": "jest",
"test:ci": "jest --coverage",
"test:watch": "jest --watchAll",
"precommit": "lint-staged",
"dev": "tsup --legacy-output --watch",
"fix": "TIMING=1 eslint src/**/*.ts* --fix"
},
"tsup": {
"clean": true,
"entry": [
"src/index.ts"
],
"format": [
"cjs",
"esm"
],
"target": "es2020",
"minify": true,
"sourcemap": true,
"tsconfig": "./tsconfig.build.json"
},
"peerDependencies": {
"@committed/components": ">= 8.1.2",
"@committed/graph": "*",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0"
},
"devDependencies": {
"@committed/config": "*"
"@committed/config": "*",
"@committed/graph": "*",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"dependencies": {
"@committed/graph": "*",
"cytoscape-cola": "^2.4.0",
"react-cytoscapejs": "^1.2.1",
"tinycolor2": "^1.4.2",
Expand Down
Loading

0 comments on commit e699702

Please sign in to comment.