chore!: only include ESM in the npm package (#266)
Get rid of the UMD bundle: not pratical, not minimified so not ready for production, nor for reuse. This lets remove the webpack build which was not used anymore. - core build: everything is done with tsc and simplify pack - remove webpack configuration - Move typedoc in the package where it is used (make it easier to detect usage) - remove unused dependencies: - better-docs (use typedoc instead) - webpack loaders (css, file, style, url) - babel - circular-dependency-plugin (webpack plugin) - webpack - cross-env - core build: tsc only BREAKING CHANGE: the UMD bundle is no more provided in the npm packagedevelopment
parent
9e6c854aa8
commit
ac48ea0d86
|
@ -43,15 +43,9 @@ jobs:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: '.nvmrc'
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Build @maxgraph/core - umd
|
|
||||||
working-directory: packages/core
|
|
||||||
run: npm run build
|
|
||||||
- name: Build @maxgraph/core - esm
|
- name: Build @maxgraph/core - esm
|
||||||
working-directory: packages/core
|
working-directory: packages/core
|
||||||
run: npm run generate-esm
|
run: npm run build
|
||||||
- name: Generate @maxgraph/core types
|
|
||||||
working-directory: packages/core
|
|
||||||
run: npm run generate-types
|
|
||||||
- name: Test @maxgraph/core
|
- name: Test @maxgraph/core
|
||||||
working-directory: packages/core
|
working-directory: packages/core
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
presets: [
|
|
||||||
'@babel/preset-env',
|
|
||||||
'@babel/preset-react',
|
|
||||||
'@babel/preset-typescript'
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
'@babel/plugin-proposal-class-properties'
|
|
||||||
]
|
|
||||||
};
|
|
18
package.json
18
package.json
|
@ -20,31 +20,15 @@
|
||||||
"prettier": "prettier --write packages/*/src/**/*.ts"
|
"prettier": "prettier --write packages/*/src/**/*.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.16.0",
|
|
||||||
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
||||||
"@babel/preset-env": "^7.16.4",
|
|
||||||
"@babel/preset-react": "^7.16.0",
|
|
||||||
"@babel/preset-typescript": "^7.16.0",
|
|
||||||
"@lerna/filter-options": "^4.0.0",
|
"@lerna/filter-options": "^4.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
||||||
"@typescript-eslint/parser": "^5.39.0",
|
"@typescript-eslint/parser": "^5.39.0",
|
||||||
"babel-loader": "^8.2.3",
|
|
||||||
"better-docs": "^2.3.2",
|
|
||||||
"cross-env": "~7.0.3",
|
|
||||||
"css-loader": "^6.5.1",
|
|
||||||
"eslint": "^8.26.0",
|
"eslint": "^8.26.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"file-loader": "^6.2.0",
|
|
||||||
"lerna": "^4.0.0",
|
"lerna": "^4.0.0",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"style-loader": "^3.3.1",
|
"typescript": "^4.9.5"
|
||||||
"typedoc": "^0.23.21",
|
|
||||||
"typescript": "^4.9.5",
|
|
||||||
"url-loader": "^4.1.1",
|
|
||||||
"webpack": "^5.64.4",
|
|
||||||
"webpack-cli": "^4.9.1",
|
|
||||||
"webpack-merge": "^5.8.0"
|
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@types/node": "^16.18.0"
|
"@types/node": "^16.18.0"
|
||||||
|
|
|
@ -11,9 +11,8 @@
|
||||||
"graph",
|
"graph",
|
||||||
"svg"
|
"svg"
|
||||||
],
|
],
|
||||||
"main": "dist/maxgraph.js",
|
"module": "dist/index.js",
|
||||||
"module": "dist/esm/index.js",
|
"types": "dist/index.d.ts",
|
||||||
"types": "dist/types/index.d.ts",
|
|
||||||
"files": [
|
"files": [
|
||||||
"css",
|
"css",
|
||||||
"dist",
|
"dist",
|
||||||
|
@ -29,19 +28,17 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tsc --watch",
|
"dev": "tsc --watch",
|
||||||
"build": "cross-env NODE_ENV=production webpack --mode=production",
|
"build": "tsc --version && tsc",
|
||||||
"docs:api": "typedoc src/index.ts",
|
"docs:api": "typedoc src/index.ts",
|
||||||
"generate-types": "tsc --version && tsc --emitDeclarationOnly",
|
"prepack": "run-s build",
|
||||||
"generate-esm": "tsc --version && tsc --emitDeclarationOnly false --declaration false --declarationDir null",
|
|
||||||
"prepack": "run-s generate-types generate-esm build",
|
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"circular-dependency-plugin": "^5.2.2",
|
|
||||||
"jest": "^29.3.1",
|
"jest": "^29.3.1",
|
||||||
"jest-environment-jsdom": "^29.3.1",
|
"jest-environment-jsdom": "^29.3.1",
|
||||||
"npm-run-all": "~4.1.5",
|
"npm-run-all": "~4.1.5",
|
||||||
"ts-jest": "^29.0.3",
|
"ts-jest": "^29.0.3",
|
||||||
|
"typedoc": "^0.23.21",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
},
|
},
|
||||||
"sideEffects": true
|
"sideEffects": true
|
||||||
|
|
|
@ -3,10 +3,9 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationDir": "./dist/types",
|
|
||||||
"declarationMap": false,
|
"declarationMap": false,
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"outDir": "./dist/esm",
|
"outDir": "./dist",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"skipLibCheck": false,
|
"skipLibCheck": false,
|
||||||
"forceConsistentCasingInFileNames": true
|
"forceConsistentCasingInFileNames": true
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
const path = require('path');
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const { merge } = require('webpack-merge');
|
|
||||||
const base = require('../../webpack.config');
|
|
||||||
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
|
||||||
|
|
||||||
module.exports = merge(base, {
|
|
||||||
entry: './src/index.ts',
|
|
||||||
output: {
|
|
||||||
filename: 'maxgraph.js',
|
|
||||||
path: path.resolve(__dirname, 'dist'),
|
|
||||||
library: 'maxgraph',
|
|
||||||
libraryTarget: 'umd',
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.(sa|sc|c)ss$/,
|
|
||||||
use: ['style-loader', 'css-loader'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(ico|png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
|
|
||||||
loader: 'url-loader',
|
|
||||||
options: {
|
|
||||||
name: 'images/[hash].[ext]',
|
|
||||||
limit: 10000,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new webpack.optimize.LimitChunkCountPlugin({
|
|
||||||
maxChunks: 1,
|
|
||||||
}),
|
|
||||||
new CircularDependencyPlugin({
|
|
||||||
// exclude detection of files based on a RegExp
|
|
||||||
exclude: /a\.js|node_modules/,
|
|
||||||
// include specific files based on a RegExp
|
|
||||||
// include: /dir/,
|
|
||||||
// add errors to webpack instead of warnings
|
|
||||||
failOnError: true,
|
|
||||||
// allow import cycles that include an asynchronous import,
|
|
||||||
// e.g. via import(/* webpackMode: "weak" */ './file.js')
|
|
||||||
allowAsyncCycles: false,
|
|
||||||
// set the current working directory for displaying module paths
|
|
||||||
cwd: process.cwd(),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
|
@ -1,20 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
devtool: 'inline-source-map',
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.(js|ts)$/,
|
|
||||||
use: {
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
rootMode: 'upward',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
exclude: /node_modules/,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: ['.ts', '.js', '.css'],
|
|
||||||
},
|
|
||||||
};
|
|
Loading…
Reference in New Issue