Skip to content

Commit

Permalink
chore(*): upgrade rollup and outdated plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
lyngai committed Aug 3, 2023
1 parent d4f2265 commit 31701bc
Show file tree
Hide file tree
Showing 14 changed files with 1,484 additions and 1,378 deletions.
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Declare files that will always have LF line endings on checkout.
* text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
Expand All @@ -13,4 +11,6 @@
*.ttf binary
*.woff binary
*.woff2 binary
*.ico binary
*.ico binary

dist/** filter=lfs diff=lfs merge=lfs -text
3 changes: 3 additions & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; }
git lfs post-checkout "$@"
3 changes: 3 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; }
git lfs post-commit "$@"
3 changes: 3 additions & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; }
git lfs post-merge "$@"
3 changes: 3 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; }
git lfs pre-push "$@"
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.20.1
6 changes: 2 additions & 4 deletions build/addons.build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const babel = require('@rollup/plugin-babel').default;
// node-resolve升级会导致出现新问题
const resolve = require('rollup-plugin-node-resolve');
const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const eslint = require('@rollup/plugin-eslint');
const alias = require('@rollup/plugin-alias');
Expand Down Expand Up @@ -28,7 +27,7 @@ glob(
);

const rollup = require('rollup');
const { terser } = require('rollup-plugin-terser');
const terser = require('@rollup/plugin-terser').default;

/**
*
Expand Down Expand Up @@ -66,7 +65,6 @@ function buildAddons(entries) {
],
}),
resolve({
ignoreGlobal: false,
browser: true,
}),
typescript({
Expand Down
2 changes: 1 addition & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';
import baseConfig from './rollup.base.config';

const terserPlugin = (options = {}) =>
Expand Down
23 changes: 12 additions & 11 deletions build/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/
import path from 'path';
import babel from '@rollup/plugin-babel';
// node-resolve升级会导致出现新问题
import resolve from 'rollup-plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import scss from 'rollup-plugin-scss';
import eslint from '@rollup/plugin-eslint';
Expand Down Expand Up @@ -52,6 +51,8 @@ export default {
globals: {
jsdom: 'jsdom',
},
// disable code splitting
manualChunks: () => 'cherry',
},
plugins: [
eslint({
Expand All @@ -61,13 +62,14 @@ export default {
envReplacePlugin(),
alias(aliasPluginOptions),
resolve({
ignoreGlobal: false,
// ignoreGlobal: false,
browser: true,
}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: [/node_modules/, /src[\\/]libs/], // Default: undefined
exclude: [/node_modules[\\/](lodash-es|d3-.*[\\/]src|d3[\\/]src|dagre-d3-es)/],
// exclude: [/src\/(?!libs)/],
// exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ], // Default: undefined
// these values can also be regular expressions
Expand Down Expand Up @@ -95,7 +97,7 @@ export default {
}),
scss({
// Filename to write all styles to
output: IS_PRODUCTION ? 'dist/cherry-markdown.min.css' : 'dist/cherry-markdown.css',
fileName: IS_PRODUCTION ? 'dist/cherry-markdown.min.css' : 'dist/cherry-markdown.css',

// Determine if node process should be terminated on error (default: false)
failOnError: true,
Expand All @@ -106,7 +108,7 @@ export default {
}),
babel({
babelHelpers: 'runtime',
exclude: [/node_modules[\\/](?!codemirror[\\/]src[\\/]|parse5)/],
exclude: [/node_modules[\\/](?!codemirror[\\/]src[\\/]|parse5|lodash-es|d3-.*[\\/]src|d3[\\/]src|dagre-d3-es)/],
}),
// TODO: 重构抽出为独立的插件
{
Expand Down Expand Up @@ -138,16 +140,15 @@ export default {
},
],
onwarn(warning, warn) {
// 忽略 mermaid 的 eval
if (warning.code === 'EVAL' && warning.id.indexOf('mermaid') !== -1) {
return;
}
// 忽略 juice 的 circular dependency
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.importer.includes('node_modules/juice')) {
if (
warning.code === 'CIRCULAR_DEPENDENCY' &&
(warning.importer.includes('node_modules/juice') || warning.importer.includes('node_modules/d3-'))
) {
return;
}
warn(warning);
},
external: [/@babel[\\/]runtime/, 'jsdom'],
external: ['jsdom'],
// external: ['echarts']
};
3 changes: 2 additions & 1 deletion build/rollup.core.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';
import baseConfig from './rollup.base.config';

const terserPlugin = (options = {}) =>
Expand All @@ -40,6 +40,7 @@ const options = {
sourcemap: false,
compact: true,
plugins: [terserPlugin()],
manualChunks: () => 'main',
},
};

Expand Down
2 changes: 1 addition & 1 deletion build/rollup.engine.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';
import baseConfig from './rollup.base.config';

// TODO: 新增完整版引擎构建, 目前引擎构建仅支持核心构建
Expand Down
34 changes: 18 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"release": "standard-version",
"prepare": "husky install",
"publish": "git push --follow-tags origin main",
"examples": "anywhere -p 3000 -s"
"examples": "serve -p 3000 ."
},
"keywords": [
"markdown"
Expand All @@ -74,8 +74,9 @@
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-eslint": "^8.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-replace": "^2.3.1",
"@rollup/plugin-terser": "^0.4.3",
"@types/echarts": "4.9.15",
"@types/glob": "^7.2.0",
"@types/jest": "^27.0.3",
Expand All @@ -86,18 +87,18 @@
"@types/virtual-dom": "^2.1.0",
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0",
"anywhere": "^1.5.0",
"async": "^3.2.4",
"babel-jest": "27",
"babel-plugin-prismjs": "^2.1.0",
"cm-search-replace": "^1.0.0",
"codemirror": "5.58.2",
"commitizen": "^4.0.5",
"core-js-pure": "^3.8.2",
"cross-env": "^7.0.2",
"cz-customizable": "^6.2.0",
"dom-parser": "^0.1.6",
"dompurify": "^2.0.11",
"es-check": "^5.1.0",
"es-check": "^7.1.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-tencent": "^1.0.2",
Expand All @@ -118,21 +119,22 @@
"lint-staged": "~12.5.0",
"lodash": "^4.17.20",
"md5": "^2.2.1",
"mitt": "^3.0.0",
"npm-run-all": "^4.1.5",
"openai": "^3.3.0",
"postcss": "^8.2.15",
"prettier": "2.6.2",
"prismjs": "^1.24.1",
"rimraf": "^3.0.2",
"rollup": "^1.27.5",
"rollup-plugin-livereload": "^1.3.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^4.0.1",
"rollup-plugin-scss": "^3.0.0",
"rollup-plugin-serve": "^1.0.1",
"rollup": "~2.79.1",
"rollup-plugin-livereload": "~2.0.5",
"rollup-plugin-postcss": "~3.1.8",
"rollup-plugin-scss": "^4.0.0",
"rollup-plugin-serve": "^2.0.2",
"rollup-plugin-serve-proxy": "^1.1.4",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-typescript2": "^0.32.1",
"sass": "^1.52.3",
"serve": "^14.2.0",
"standard-version": "^9.3.2",
"ts-jest": "^27.1.1",
"ts-node": "^10.7.0",
Expand All @@ -142,10 +144,7 @@
"dependencies": {
"@types/codemirror": "^0.0.108",
"@types/dompurify": "^2.2.3",
"cm-search-replace": "^1.0.0",
"jsdom": "~19.0.0",
"mitt": "^3.0.0",
"openai": "^3.3.0"
"jsdom": "~19.0.0"
},
"resolutions": {
"glob-parent": "5.1.2",
Expand All @@ -161,9 +160,12 @@
}
},
"optionalDependencies": {
"mermaid": "10.2.4"
"mermaid": "9.4.3"
},
"lint-staged": {
"*.js": "eslint --fix"
},
"engines": {
"node": ">=14"
}
}
7 changes: 4 additions & 3 deletions types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as mermaid from 'mermaid';
import Mermaid from 'mermaid';

// for IE
export {};

Expand All @@ -7,8 +8,8 @@ declare global {
interface Window {
// for IE
clipboardData: ClipboardEvent['clipboardData'];
mermaid?: mermaid.Mermaid;
mermaidAPI?: mermaid.Mermaid['mermaidAPI'];
mermaid?: typeof Mermaid;
mermaidAPI?: typeof Mermaid['mermaidAPI'];
echarts?: echarts.ECharts;
MathJax?: any;
}
Expand Down
Loading

0 comments on commit 31701bc

Please sign in to comment.