This commit is contained in:
Knut Sveidqvist 2021-08-04 20:02:16 +02:00
commit eb4ac5c103
25 changed files with 63089 additions and 2483 deletions

View File

@ -4,7 +4,7 @@
"es6": true, "es6": true,
"node": true "node": true
}, },
"parser": "babel-eslint", "parser": "@babel/eslint-parser",
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
"experimentalObjectRestSpread": true, "experimentalObjectRestSpread": true,

View File

@ -1,13 +1,12 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: npm - package-ecosystem: npm
directory: / directory: /
target-branch: develop target-branch: develop
schedule: schedule:
interval: daily interval: weekly
- package-ecosystem: github-actions - package-ecosystem: github-actions
directory: / directory: /
target-branch: develop target-branch: develop
schedule: schedule:
interval: daily interval: weekly

View File

@ -9,10 +9,10 @@ jobs:
matrix: matrix:
node-version: [16.x] node-version: [16.x]
steps: steps:
- uses: actions/checkout@v2.3.4 - uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }} - name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.2.0 uses: actions/setup-node@v2
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
@ -20,7 +20,7 @@ jobs:
run: npm i yarn --global run: npm i yarn --global
- name: Cache Node Modules - name: Cache Node Modules
uses: actions/cache@v2.1.5 uses: actions/cache@v2
with: with:
path: .cache path: .cache
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
@ -36,7 +36,7 @@ jobs:
run: yarn build run: yarn build
- name: Upload Build as Artifact - name: Upload Build as Artifact
uses: actions/upload-artifact@v2.2.3 uses: actions/upload-artifact@v2
with: with:
name: dist name: dist
path: dist path: dist
@ -61,4 +61,4 @@ jobs:
# uses: coverallsapp/github-action@master # uses: coverallsapp/github-action@master
# with: # with:
# github-token: ${{ secrets.GITHUB_TOKEN }} # github-token: ${{ secrets.GITHUB_TOKEN }}
# parallel-finished: true # parallel-finished: true

View File

@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2.3.4 - uses: actions/checkout@v2.3.4
- name: Setup Node.js ${{ matrix.node-version }} - name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.2.0 uses: actions/setup-node@v2
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
@ -20,7 +20,7 @@ jobs:
run: npm i yarn --global run: npm i yarn --global
- name: Cache Node Modules - name: Cache Node Modules
uses: actions/cache@v2.1.5 uses: actions/cache@v2
with: with:
path: .cache path: .cache
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
@ -55,4 +55,4 @@ jobs:
# uses: coverallsapp/github-action@master # uses: coverallsapp/github-action@master
# with: # with:
# github-token: ${{ secrets.GITHUB_TOKEN }} # github-token: ${{ secrets.GITHUB_TOKEN }}
# parallel-finished: true # parallel-finished: true

View File

@ -8,7 +8,7 @@ jobs:
triage: triage:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: andymckay/labeler@1.0.2 - uses: andymckay/labeler@1
with: with:
repo-token: "${{ secrets.GITHUB_TOKEN }}" repo-token: "${{ secrets.GITHUB_TOKEN }}"
labels: "Status: Triage" labels: "Status: Triage"

View File

@ -10,6 +10,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Draft Release - name: Draft Release
uses: toolmantim/release-drafter@v5.2.0 uses: toolmantim/release-drafter@v5
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -9,9 +9,9 @@ jobs:
publish: publish:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2.3.4 - uses: actions/checkout@v2
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v2.2.0 uses: actions/setup-node@v2
with: with:
node-version: 16.x node-version: 16.x
- name: Install Yarn - name: Install Yarn

View File

@ -12,7 +12,7 @@ jobs:
- uses: fregante/setup-git-user@v1 - uses: fregante/setup-git-user@v1
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v2.2.0 uses: actions/setup-node@v2
with: with:
node-version: 16.x node-version: 16.x
- name: Install Yarn - name: Install Yarn

View File

@ -3,8 +3,8 @@ module.exports = {
[ [
'@babel/preset-env', '@babel/preset-env',
{ {
targets: "defaults, ie >= 11, current node" targets: 'defaults, ie >= 11, current node',
} },
] ],
] ],
} };

12
dist/mermaid.core.js vendored
View File

@ -653,10 +653,10 @@ module.exports = function(module) {
/*!**********************!*\ /*!**********************!*\
!*** ./package.json ***! !*** ./package.json ***!
\**********************/ \**********************/
/*! exports provided: name, version, description, main, keywords, scripts, repository, author, license, standard, dependencies, devDependencies, files, yarn-upgrade-all, sideEffects, husky, default */ /*! exports provided: name, version, description, main, keywords, scripts, repository, author, license, standard, dependencies, devDependencies, files, sideEffects, husky, default */
/***/ (function(module) { /***/ (function(module) {
module.exports = JSON.parse("{\"name\":\"mermaid\",\"version\":\"8.11.2\",\"description\":\"Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.\",\"main\":\"dist/mermaid.core.js\",\"keywords\":[\"diagram\",\"markdown\",\"flowchart\",\"sequence diagram\",\"gantt\",\"class diagram\",\"git graph\"],\"scripts\":{\"build:development\":\"webpack --progress --colors\",\"build:production\":\"yarn build:development -p --config webpack.config.prod.babel.js\",\"build\":\"yarn build:development && yarn build:production\",\"postbuild\":\"documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md\",\"build:watch\":\"yarn build --watch\",\"release\":\"yarn build\",\"lint\":\"eslint src\",\"e2e:depr\":\"yarn lint && jest e2e --config e2e/jest.config.js\",\"cypress\":\"percy exec -- cypress run\",\"e2e\":\"start-server-and-test dev http://localhost:9000/ cypress\",\"e2e-upd\":\"yarn lint && jest e2e -u --config e2e/jest.config.js\",\"dev\":\"webpack-dev-server --config webpack.config.e2e.js\",\"test\":\"yarn lint && jest src/.*\",\"test:watch\":\"jest --watch src\",\"prepublishOnly\":\"yarn build && yarn test\",\"prepare\":\"yarn build\"},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/knsv/mermaid\"},\"author\":\"Knut Sveidqvist\",\"license\":\"MIT\",\"standard\":{\"ignore\":[\"**/parser/*.js\",\"dist/**/*.js\",\"cypress/**/*.js\"],\"globals\":[\"page\"]},\"dependencies\":{\"@braintree/sanitize-url\":\"^3.1.0\",\"@percy/migrate\":\"^0.10.0\",\"d3\":\"^5.7.0\",\"dagre\":\"^0.8.5\",\"dagre-d3\":\"^0.6.4\",\"dompurify\":\"2.3.0\",\"graphlib\":\"^2.1.8\",\"khroma\":\"^1.4.1\",\"moment-mini\":\"^2.24.0\",\"stylis\":\"^4.0.10\"},\"devDependencies\":{\"@babel/core\":\"^7.14.6\",\"@babel/preset-env\":\"^7.14.7\",\"@babel/register\":\"^7.14.5\",\"@percy/cli\":\"^1.0.0-beta.58\",\"@percy/cypress\":\"^3.1.0\",\"babel-core\":\"7.0.0-bridge.0\",\"babel-eslint\":\"^10.1.0\",\"babel-jest\":\"^27.0.6\",\"babel-loader\":\"^8.2.2\",\"coveralls\":\"^3.0.2\",\"css-to-string-loader\":\"^0.1.3\",\"cypress\":\"7.6.0\",\"documentation\":\"13.2.0\",\"eslint\":\"^7.30.0\",\"eslint-config-prettier\":\"^8.3.0\",\"eslint-plugin-prettier\":\"^3.4.0\",\"husky\":\"^7.0.1\",\"identity-obj-proxy\":\"^3.0.0\",\"jest\":\"^27.0.6\",\"jison\":\"^0.4.18\",\"js-base64\":\"3.6.1\",\"moment\":\"^2.23.0\",\"prettier\":\"^2.3.2\",\"start-server-and-test\":\"^1.12.6\",\"terser-webpack-plugin\":\"^2.2.2\",\"webpack\":\"^4.41.2\",\"webpack-bundle-analyzer\":\"^4.4.2\",\"webpack-cli\":\"^3.1.2\",\"webpack-dev-server\":\"^3.4.1\",\"webpack-node-externals\":\"^1.7.2\"},\"files\":[\"dist\"],\"yarn-upgrade-all\":{\"ignore\":[\"babel-core\"]},\"sideEffects\":[\"**/*.css\",\"**/*.scss\"],\"husky\":{\"hooks\":{\"pre-push\":\"yarn test\"}}}"); module.exports = JSON.parse("{\"name\":\"mermaid\",\"version\":\"8.11.0\",\"description\":\"Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.\",\"main\":\"dist/mermaid.core.js\",\"keywords\":[\"diagram\",\"markdown\",\"flowchart\",\"sequence diagram\",\"gantt\",\"class diagram\",\"git graph\"],\"scripts\":{\"build:development\":\"webpack --progress --color\",\"build:production\":\"yarn build:development --mode production --config webpack.config.prod.babel.js\",\"build\":\"yarn build:development && yarn build:production\",\"postbuild\":\"documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md\",\"build:watch\":\"yarn build --watch\",\"release\":\"yarn build\",\"lint\":\"eslint src\",\"e2e:depr\":\"yarn lint && jest e2e --config e2e/jest.config.js\",\"cypress\":\"percy exec -- cypress run\",\"e2e\":\"start-server-and-test dev http://localhost:9000/ cypress\",\"e2e-upd\":\"yarn lint && jest e2e -u --config e2e/jest.config.js\",\"dev\":\"webpack serve --config webpack.config.e2e.js\",\"test\":\"yarn lint && jest src/.*\",\"test:watch\":\"jest --watch src\",\"prepublishOnly\":\"yarn build && yarn test\",\"prepare\":\"yarn build\"},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/knsv/mermaid\"},\"author\":\"Knut Sveidqvist\",\"license\":\"MIT\",\"standard\":{\"ignore\":[\"**/parser/*.js\",\"dist/**/*.js\",\"cypress/**/*.js\"],\"globals\":[\"page\"]},\"dependencies\":{\"@braintree/sanitize-url\":\"^3.1.0\",\"@percy/migrate\":\"^0.11.0\",\"d3\":\"^7.0.0\",\"dagre\":\"^0.8.5\",\"dagre-d3\":\"^0.6.4\",\"graphlib\":\"^2.1.8\",\"khroma\":\"^1.4.1\",\"moment-mini\":\"^2.24.0\",\"stylis\":\"^4.0.10\"},\"devDependencies\":{\"@babel/core\":\"^7.14.6\",\"@babel/eslint-parser\":\"^7.14.7\",\"@babel/preset-env\":\"^7.14.7\",\"@babel/register\":\"^7.14.5\",\"@percy/cli\":\"^1.0.0-beta.58\",\"@percy/cypress\":\"^3.1.0\",\"babel-jest\":\"^27.0.6\",\"babel-loader\":\"^8.2.2\",\"coveralls\":\"^3.0.2\",\"css-to-string-loader\":\"^0.1.3\",\"cypress\":\"8.0.0\",\"documentation\":\"13.2.0\",\"dompurify\":\"2.3.0\",\"eslint\":\"^7.30.0\",\"eslint-config-prettier\":\"^8.3.0\",\"eslint-plugin-prettier\":\"^3.4.0\",\"husky\":\"^7.0.1\",\"identity-obj-proxy\":\"^3.0.0\",\"jest\":\"^27.0.6\",\"jison\":\"^0.4.18\",\"js-base64\":\"3.6.1\",\"moment\":\"^2.23.0\",\"prettier\":\"^2.3.2\",\"start-server-and-test\":\"^1.12.6\",\"terser-webpack-plugin\":\"^4.2.3\",\"webpack\":\"^4.41.2\",\"webpack-cli\":\"^4.7.2\",\"webpack-dev-server\":\"^3.4.1\",\"webpack-node-externals\":\"^3.0.0\"},\"files\":[\"dist\"],\"sideEffects\":[\"**/*.css\",\"**/*.scss\"],\"husky\":{\"hooks\":{\"pre-push\":\"yarn test\"}}}");
/***/ }), /***/ }),
@ -3283,10 +3283,8 @@ var rectWithTitle = function rectWithTitle(parent, node) {
var halfPadding = node.padding / 2; var halfPadding = node.padding / 2;
Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])(descr).attr('transform', 'translate( ' + ( // (titleBox.width - bbox.width) / 2 + Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])(descr).attr('transform', 'translate( ' + (bbox.width > titleBox.width ? 0 : (titleBox.width - bbox.width) / 2) + ', ' + (titleBox.height + halfPadding + 5) + ')');
bbox.width > titleBox.width ? 0 : (titleBox.width - bbox.width) / 2) + ', ' + (titleBox.height + halfPadding + 5) + ')'); Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])(text).attr('transform', 'translate( ' + (bbox.width < titleBox.width ? 0 : -(titleBox.width - bbox.width) / 2) + ', ' + 0 + ')'); // Get the size of the label
Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])(text).attr('transform', 'translate( ' + ( // (titleBox.width - bbox.width) / 2 +
bbox.width < titleBox.width ? 0 : -(titleBox.width - bbox.width) / 2) + ', ' + 0 + ')'); // Get the size of the label
// Bounding box for title and text // Bounding box for title and text
bbox = label.node().getBBox(); // Center the label bbox = label.node().getBBox(); // Center the label
@ -16931,7 +16929,7 @@ var draw = function draw(txt, id) {
var pie = Object(d3__WEBPACK_IMPORTED_MODULE_0__["pie"])().value(function (d) { var pie = Object(d3__WEBPACK_IMPORTED_MODULE_0__["pie"])().value(function (d) {
return d.value; return d.value;
}); });
var dataReady = pie(Object(d3__WEBPACK_IMPORTED_MODULE_0__["entries"])(data)); // Shape helper to build arcs: var dataReady = pie(Object.entries(data)); // Shape helper to build arcs:
var arcGenerator = Object(d3__WEBPACK_IMPORTED_MODULE_0__["arc"])().innerRadius(0).outerRadius(radius); // Build the pie chart: each part of the pie is a path that we build using the arc function. var arcGenerator = Object(d3__WEBPACK_IMPORTED_MODULE_0__["arc"])().innerRadius(0).outerRadius(radius); // Build the pie chart: each part of the pie is a path that we build using the arc function.

File diff suppressed because one or more lines are too long

64076
dist/mermaid.js vendored

File diff suppressed because one or more lines are too long

2
dist/mermaid.js.map vendored

File diff suppressed because one or more lines are too long

12
dist/mermaid.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,14 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
testEnvironment:"jsdom", testEnvironment: 'jsdom',
transform: { transform: {
'^.+\\.jsx?$': './transformer.js', '^.+\\.jsx?$': './transformer.js',
'^.+\\.jison$': path.resolve(__dirname, './jisonTransformer.js') '^.+\\.jison$': path.resolve(__dirname, './jisonTransformer.js'),
}, },
transformIgnorePatterns: ['/node_modules/(?!dagre-d3-renderer/lib).*\\.js'], transformIgnorePatterns: ['/node_modules/(?!dagre-d3-renderer/lib).*\\.js'],
moduleNameMapper: { moduleNameMapper: {
'\\.(css|scss)$': 'identity-obj-proxy' '\\.(css|scss)$': 'identity-obj-proxy',
}, },
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node', 'jison'] moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node', 'jison'],
}; };

View File

@ -1,6 +1,6 @@
const { Generator } = require('jison') const { Generator } = require('jison');
const { getOptions } = require('loader-utils') const { getOptions } = require('loader-utils');
module.exports = function jisonLoader (source) { module.exports = function jisonLoader(source) {
return new Generator(source, getOptions(this)).generate() return new Generator(source, getOptions(this)).generate();
} };

View File

@ -3,7 +3,7 @@ const { Generator } = require('jison');
module.exports = { module.exports = {
process(source, filename, config, transformOptions) { process(source, filename, config, transformOptions) {
return new Generator(source, { return new Generator(source, {
'token-stack': true 'token-stack': true,
}).generate(); }).generate();
} },
}; };

View File

@ -13,8 +13,8 @@
"git graph" "git graph"
], ],
"scripts": { "scripts": {
"build:development": "webpack --progress --colors", "build:development": "webpack --progress --color",
"build:production": "yarn build:development -p --config webpack.config.prod.babel.js", "build:production": "yarn build:development --mode production --config webpack.config.prod.babel.js",
"build": "yarn build:development && yarn build:production", "build": "yarn build:development && yarn build:production",
"postbuild": "documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md", "postbuild": "documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md",
"build:watch": "yarn build --watch", "build:watch": "yarn build --watch",
@ -24,7 +24,7 @@
"cypress": "percy exec -- cypress run", "cypress": "percy exec -- cypress run",
"e2e": "start-server-and-test dev http://localhost:9000/ cypress", "e2e": "start-server-and-test dev http://localhost:9000/ cypress",
"e2e-upd": "yarn lint && jest e2e -u --config e2e/jest.config.js", "e2e-upd": "yarn lint && jest e2e -u --config e2e/jest.config.js",
"dev": "webpack-dev-server --config webpack.config.e2e.js", "dev": "webpack serve --config webpack.config.e2e.js",
"test": "yarn lint && jest src/.*", "test": "yarn lint && jest src/.*",
"test:watch": "jest --watch src", "test:watch": "jest --watch src",
"prepublishOnly": "yarn build && yarn test", "prepublishOnly": "yarn build && yarn test",
@ -48,8 +48,8 @@
}, },
"dependencies": { "dependencies": {
"@braintree/sanitize-url": "^3.1.0", "@braintree/sanitize-url": "^3.1.0",
"@percy/migrate": "^0.10.0", "@percy/migrate": "^0.11.0",
"d3": "^5.7.0", "d3": "^7.0.0",
"dagre": "^0.8.5", "dagre": "^0.8.5",
"dagre-d3": "^0.6.4", "dagre-d3": "^0.6.4",
"dompurify": "2.3.0", "dompurify": "2.3.0",
@ -60,17 +60,16 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.14.6", "@babel/core": "^7.14.6",
"@babel/eslint-parser": "^7.14.7",
"@babel/preset-env": "^7.14.7", "@babel/preset-env": "^7.14.7",
"@babel/register": "^7.14.5", "@babel/register": "^7.14.5",
"@percy/cli": "^1.0.0-beta.58", "@percy/cli": "^1.0.0-beta.58",
"@percy/cypress": "^3.1.0", "@percy/cypress": "^3.1.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.0.6", "babel-jest": "^27.0.6",
"babel-loader": "^8.2.2", "babel-loader": "^8.2.2",
"coveralls": "^3.0.2", "coveralls": "^3.0.2",
"css-to-string-loader": "^0.1.3", "css-to-string-loader": "^0.1.3",
"cypress": "7.6.0", "cypress": "8.1.0",
"documentation": "13.2.0", "documentation": "13.2.0",
"eslint": "^7.30.0", "eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
@ -83,21 +82,15 @@
"moment": "^2.23.0", "moment": "^2.23.0",
"prettier": "^2.3.2", "prettier": "^2.3.2",
"start-server-and-test": "^1.12.6", "start-server-and-test": "^1.12.6",
"terser-webpack-plugin": "^2.2.2", "terser-webpack-plugin": "^4.2.3",
"webpack": "^4.41.2", "webpack": "^4.41.2",
"webpack-bundle-analyzer": "^4.4.2", "webpack-cli": "^4.7.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.4.1", "webpack-dev-server": "^3.4.1",
"webpack-node-externals": "^1.7.2" "webpack-node-externals": "^3.0.0"
}, },
"files": [ "files": [
"dist" "dist"
], ],
"yarn-upgrade-all": {
"ignore": [
"babel-core"
]
},
"sideEffects": [ "sideEffects": [
"**/*.css", "**/*.css",
"**/*.scss" "**/*.scss"

View File

@ -1,7 +1,7 @@
/** /**
* Created by AshishJ on 11-09-2019. * Created by AshishJ on 11-09-2019.
*/ */
import { select, scaleOrdinal, pie as d3pie, entries, arc } from 'd3'; import { select, scaleOrdinal, pie as d3pie, arc } from 'd3';
import pieData from './pieDb'; import pieData from './pieDb';
import pieParser from './parser/pie'; import pieParser from './parser/pie';
import { log } from '../../logger'; import { log } from '../../logger';
@ -87,7 +87,7 @@ export const draw = (txt, id) => {
var pie = d3pie().value(function (d) { var pie = d3pie().value(function (d) {
return d.value; return d.value;
}); });
var dataReady = pie(entries(data)); var dataReady = pie(Object.entries(data));
// Shape helper to build arcs: // Shape helper to build arcs:
var arcGenerator = arc().innerRadius(0).outerRadius(radius); var arcGenerator = arc().innerRadius(0).outerRadius(radius);

View File

@ -1,11 +1,11 @@
import nodeExternals from 'webpack-node-externals' import nodeExternals from 'webpack-node-externals';
import { jsConfig } from './webpack.config.base' import { jsConfig } from './webpack.config.base';
const config = jsConfig() const config = jsConfig();
const coreConfig = jsConfig() const coreConfig = jsConfig();
coreConfig.externals = [nodeExternals()] coreConfig.externals = [nodeExternals()];
coreConfig.output.filename = '[name].core.js' coreConfig.output.filename = '[name].core.js';
export default [config, coreConfig] export default [config, coreConfig];

View File

@ -1,10 +1,9 @@
import path from 'path'; import path from 'path';
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const amdRule = { const amdRule = {
parser: { parser: {
amd: false // https://github.com/lodash/lodash/issues/3052 amd: false, // https://github.com/lodash/lodash/issues/3052
} },
}; };
const jisonRule = { const jisonRule = {
@ -12,25 +11,25 @@ const jisonRule = {
use: { use: {
loader: path.resolve(__dirname, './jisonLoader'), loader: path.resolve(__dirname, './jisonLoader'),
options: { options: {
'token-stack': true 'token-stack': true,
} },
} },
}; };
const jsRule = { const jsRule = {
test: /\.js$/, test: /\.js$/,
include: [ include: [
path.resolve(__dirname, './src'), path.resolve(__dirname, './src'),
path.resolve(__dirname, './node_modules/dagre-d3-renderer/lib') path.resolve(__dirname, './node_modules/dagre-d3-renderer/lib'),
], ],
use: { use: {
loader: 'babel-loader' loader: 'babel-loader',
} },
}; };
const scssRule = { const scssRule = {
// load scss to string // load scss to string
test: /\.scss$/, test: /\.scss$/,
use: [{ loader: 'css-to-string-loader' }, { loader: 'css-loader' }, { loader: 'sass-loader' }] use: [{ loader: 'css-to-string-loader' }, { loader: 'css-loader' }, { loader: 'sass-loader' }],
}; };
export const jsConfig = () => { export const jsConfig = () => {
@ -38,13 +37,13 @@ export const jsConfig = () => {
mode: 'development', mode: 'development',
target: 'web', target: 'web',
entry: { entry: {
mermaid: './src/mermaid.js' mermaid: './src/mermaid.js',
}, },
resolve: { resolve: {
extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'] extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'],
}, },
node: { node: {
fs: 'empty' // jison generated code requires 'fs' fs: 'empty', // jison generated code requires 'fs'
}, },
output: { output: {
path: path.join(__dirname, './dist/'), path: path.join(__dirname, './dist/'),
@ -52,12 +51,11 @@ export const jsConfig = () => {
library: 'mermaid', library: 'mermaid',
libraryTarget: 'umd', libraryTarget: 'umd',
libraryExport: 'default', libraryExport: 'default',
globalObject: 'typeof self !== "undefined" ? self : this' globalObject: 'typeof self !== "undefined" ? self : this',
}, },
module: { module: {
rules: [amdRule, jsRule, scssRule, jisonRule] rules: [amdRule, jsRule, scssRule, jisonRule],
}, },
// plugins: [new BundleAnalyzerPlugin()], devtool: 'source-map',
devtool: 'source-map'
}; };
}; };

View File

@ -4,8 +4,8 @@ const jsRule = {
test: /\.js$/, test: /\.js$/,
exclude: /node_modules/, exclude: /node_modules/,
use: { use: {
loader: 'babel-loader' loader: 'babel-loader',
} },
}; };
const jisonRule = { const jisonRule = {
@ -13,20 +13,20 @@ const jisonRule = {
use: { use: {
loader: path.resolve(__dirname, './jisonLoader'), loader: path.resolve(__dirname, './jisonLoader'),
options: { options: {
'token-stack': true 'token-stack': true,
} },
} },
}; };
const amdRule = { const amdRule = {
parser: { parser: {
amd: false // https://github.com/lodash/lodash/issues/3052 amd: false, // https://github.com/lodash/lodash/issues/3052
} },
}; };
const scssRule = { const scssRule = {
// load scss to string // load scss to string
test: /\.scss$/, test: /\.scss$/,
use: [{ loader: 'css-to-string-loader' }, { loader: 'css-loader' }, { loader: 'sass-loader' }] use: [{ loader: 'css-to-string-loader' }, { loader: 'css-loader' }, { loader: 'sass-loader' }],
}; };
module.exports = { module.exports = {
@ -35,31 +35,31 @@ module.exports = {
entry: { entry: {
mermaid: './src/mermaid.js', mermaid: './src/mermaid.js',
e2e: './cypress/platform/viewer.js', e2e: './cypress/platform/viewer.js',
'bundle-test': './cypress/platform/bundle-test.js' 'bundle-test': './cypress/platform/bundle-test.js',
}, },
resolve: { resolve: {
extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'] extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'],
}, },
node: { node: {
fs: 'empty' // jison generated code requires 'fs' fs: 'empty', // jison generated code requires 'fs'
}, },
output: { output: {
path: path.join(__dirname, './dist/'), path: path.join(__dirname, './dist/'),
filename: '[name].js', filename: '[name].js',
library: 'mermaid', library: 'mermaid',
libraryTarget: 'umd', libraryTarget: 'umd',
libraryExport: 'default' libraryExport: 'default',
}, },
devServer: { devServer: {
contentBase: [path.join(__dirname, 'cypress', 'platform'), path.join(__dirname, 'dist')], contentBase: [path.join(__dirname, 'cypress', 'platform'), path.join(__dirname, 'dist')],
compress: true, compress: true,
port: 9000 port: 9000,
}, },
module: { module: {
rules: [amdRule, jsRule, scssRule, jisonRule] rules: [amdRule, jsRule, scssRule, jisonRule],
}, },
externals: { externals: {
mermaid: 'mermaid' mermaid: 'mermaid',
}, },
devtool: 'source-map' devtool: 'source-map',
}; };

View File

@ -1,7 +1,7 @@
import { jsConfig } from './webpack.config.base' import { jsConfig } from './webpack.config.base';
const minConfig = jsConfig() const minConfig = jsConfig();
minConfig.mode = 'production' minConfig.mode = 'production';
minConfig.output.filename = '[name].min.js' minConfig.output.filename = '[name].min.js';
export default [minConfig] export default [minConfig];

1282
yarn.lock

File diff suppressed because it is too large Load Diff