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 package
development
Thomas Bouffard 2023-12-03 16:51:40 +01:00 committed by GitHub
parent 9e6c854aa8
commit ac48ea0d86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 9 additions and 114 deletions

View File

@ -43,15 +43,9 @@ jobs:
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm install
- name: Build @maxgraph/core - umd
working-directory: packages/core
run: npm run build
- name: Build @maxgraph/core - esm
working-directory: packages/core
run: npm run generate-esm
- name: Generate @maxgraph/core types
working-directory: packages/core
run: npm run generate-types
run: npm run build
- name: Test @maxgraph/core
working-directory: packages/core
run: npm test

View File

@ -1,10 +0,0 @@
module.exports = {
presets: [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript'
],
plugins: [
'@babel/plugin-proposal-class-properties'
]
};

View File

@ -20,31 +20,15 @@
"prettier": "prettier --write packages/*/src/**/*.ts"
},
"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",
"@typescript-eslint/eslint-plugin": "^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-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"file-loader": "^6.2.0",
"lerna": "^4.0.0",
"prettier": "^2.7.1",
"style-loader": "^3.3.1",
"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"
"typescript": "^4.9.5"
},
"overrides": {
"@types/node": "^16.18.0"

View File

@ -11,9 +11,8 @@
"graph",
"svg"
],
"main": "dist/maxgraph.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"css",
"dist",
@ -29,19 +28,17 @@
},
"scripts": {
"dev": "tsc --watch",
"build": "cross-env NODE_ENV=production webpack --mode=production",
"build": "tsc --version && tsc",
"docs:api": "typedoc src/index.ts",
"generate-types": "tsc --version && tsc --emitDeclarationOnly",
"generate-esm": "tsc --version && tsc --emitDeclarationOnly false --declaration false --declarationDir null",
"prepack": "run-s generate-types generate-esm build",
"prepack": "run-s build",
"test": "jest"
},
"devDependencies": {
"circular-dependency-plugin": "^5.2.2",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"npm-run-all": "~4.1.5",
"ts-jest": "^29.0.3",
"typedoc": "^0.23.21",
"typescript": "^4.9.5"
},
"sideEffects": true

View File

@ -3,10 +3,9 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationDir": "./dist/types",
"declarationMap": false,
"emitDeclarationOnly": true,
"outDir": "./dist/esm",
"emitDeclarationOnly": false,
"outDir": "./dist",
"strict": true,
"skipLibCheck": false,
"forceConsistentCasingInFileNames": true

View File

@ -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(),
}),
],
});

View File

@ -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'],
},
};