chore: update scripts.

pull/465/head
jaywcjlove 1 year ago
parent 2767829cc7
commit aeaff2d5dd

@ -2,16 +2,24 @@ import path from 'path';
import webpack from 'webpack'; import webpack from 'webpack';
import lessModules from '@kkt/less-modules'; import lessModules from '@kkt/less-modules';
import rawModules from '@kkt/raw-modules'; import rawModules from '@kkt/raw-modules';
import { disableScopePlugin } from '@kkt/scope-plugin-options';
import scopePluginOptions from '@kkt/scope-plugin-options'; import scopePluginOptions from '@kkt/scope-plugin-options';
import pkg from './package.json'; import pkg from './package.json';
export default (conf, env, options) => { export default (conf, env, options) => {
conf = lessModules(conf, env, options); conf = lessModules(conf, env, options);
conf = rawModules(conf, env, options); conf = rawModules(conf, env, options);
conf = disableScopePlugin(conf);
conf = scopePluginOptions(conf, env, { conf = scopePluginOptions(conf, env, {
...options, ...options,
allowedFiles: [path.resolve(process.cwd(), 'README.md')], allowedFiles: [
path.resolve(process.cwd(), 'README.md'),
path.resolve(process.cwd(), 'src')
],
}); });
conf.ignoreWarnings = [
{ module: /node_modules[\\/]parse5[\\/]/ }
];
// Get the project version. // Get the project version.
conf.plugins.push( conf.plugins.push(
new webpack.DefinePlugin({ new webpack.DefinePlugin({

20006
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -8,9 +8,9 @@
"scripts": { "scripts": {
"prepare": "npm run build:lib && husky install", "prepare": "npm run build:lib && husky install",
"lint": "eslint --ignore-pattern dist --ext .js src website", "lint": "eslint --ignore-pattern dist --ext .js src website",
"build:lib": "node scripts/build.js", "build:lib": "node scripts/build.mjs",
"build": "npm run build:lib && npm run doc && npm run lint", "build": "npm run build:lib && npm run doc && npm run lint",
"watch": "node scripts/watch.js", "watch": "node scripts/watch.mjs",
"pretest": "npm run build", "pretest": "npm run build",
"test": "jest --coverage --detectOpenHandles", "test": "jest --coverage --detectOpenHandles",
"test:watch": "jest --watch", "test:watch": "jest --watch",
@ -46,18 +46,19 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/eslint-parser": "^7.18.9", "@babel/eslint-parser": "^7.18.9",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@kkt/less-modules": "^7.5.2", "@kkt/less-modules": "^7.5.2",
"@kkt/raw-modules": "^7.5.2", "@kkt/raw-modules": "^7.5.2",
"@kkt/scope-plugin-options": "^7.5.2", "@kkt/scope-plugin-options": "^7.5.2",
"@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.2", "@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-node-resolve": "^15.2.3",
"@uiw/react-github-corners": "^1.5.15", "@uiw/react-github-corners": "^1.5.15",
"@uiw/react-mac-keyboard": "^1.1.5", "@uiw/react-mac-keyboard": "^1.1.5",
"@uiw/react-markdown-preview": "^4.1.13", "@uiw/react-markdown-preview": "^5.0.3",
"@uiw/react-shields": "^1.1.3", "@uiw/react-shields": "^2.0.1",
"@wcj/dark-mode": "~1.0.15", "@wcj/dark-mode": "~1.0.15",
"bannerjs": "~2.1.0", "bannerjs": "^3.0.2",
"classnames": "^2.3.2", "classnames": "^2.3.2",
"colors-cli": "^1.0.32", "colors-cli": "^1.0.32",
"eslint": "^8.44.0", "eslint": "^8.44.0",
@ -66,14 +67,14 @@
"eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2", "eslint-plugin-react": "^7.32.2",
"husky": "^8.0.3", "husky": "^8.0.3",
"jest": "~27.5.1", "jest": "^29.7.0",
"kkt": "^7.5.2", "kkt": "^7.5.2",
"lint-staged": "^13.2.3", "lint-staged": "^15.2.0",
"puppeteer": "~13.5.2", "puppeteer": "~13.5.2",
"react": "~18.2.0", "react": "~18.2.0",
"react-dom": "~18.2.0", "react-dom": "~18.2.0",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"rollup": "^3.26.2", "rollup": "^4.7.0",
"uglify-js": "^3.17.4" "uglify-js": "^3.17.4"
}, },
"browserslist": { "browserslist": {

@ -1,22 +1,21 @@
const fs = require('fs'); import { nodeResolve } from '@rollup/plugin-node-resolve';
const path = require('path'); import commonjs from '@rollup/plugin-commonjs';
const rollup = require('rollup'); import path from 'path';
const babel = require('@rollup/plugin-babel'); import fs from 'fs';
const nodeResolve = require('@rollup/plugin-node-resolve'); import zlib from 'zlib';
const commonjs = require('@rollup/plugin-commonjs'); import { rollup } from 'rollup';
const banner = require('bannerjs'); import { multibanner, onebanner } from 'bannerjs';
const zlib = require('zlib'); import { babel } from '@rollup/plugin-babel';
// const pkg = require('../package.json'); import uglify from 'uglify-js';
const uglify = require('uglify-js'); import 'colors-cli/toxic';
require('colors-cli/toxic');
// see below for details on the options // see below for details on the options
const inputOptions = { const inputOptions = {
input: 'src/index.js', input: 'src/index.js',
plugins: [ plugins: [
nodeResolve.default(), // so Rollup can find `ms` nodeResolve(), // so Rollup can find `ms`
commonjs(), // so Rollup can convert `ms` to an ES module commonjs(), // so Rollup can convert `ms` to an ES module
babel.default({ babel({
babelHelpers: 'bundled', babelHelpers: 'bundled',
exclude: 'node_modules/**', // 只编译我们的源代码 exclude: 'node_modules/**', // 只编译我们的源代码
presets: [[ presets: [[
@ -34,7 +33,7 @@ const inputOptions = {
async function build() { async function build() {
// create a bundle // create a bundle
const bundle = await rollup.rollup(inputOptions); const bundle = await rollup(inputOptions);
const uglifyOption = { const uglifyOption = {
compress: { compress: {
@ -54,23 +53,23 @@ async function build() {
const umd = await bundle.generate({ const umd = await bundle.generate({
format: 'umd', format: 'umd',
name: 'hotkeys', name: 'hotkeys',
banner: banner.multibanner(), banner: multibanner(),
}); });
const umdMinified = `${banner.onebanner()}\n${uglify.minify(umd.output[0].code, uglifyOption).code}`; const umdMinified = `${onebanner()}\n${uglify.minify(umd.output[0].code, uglifyOption).code}`;
const common = await bundle.generate({ const common = await bundle.generate({
format: 'cjs', format: 'cjs',
name: 'hotkeys', name: 'hotkeys',
exports: 'auto', exports: 'auto',
banner: banner.multibanner(), banner: multibanner(),
}); });
const commonMinified = `${banner.onebanner()}\n${uglify.minify(common.output[0].code, uglifyOption).code}`; const commonMinified = `${onebanner()}\n${uglify.minify(common.output[0].code, uglifyOption).code}`;
const es = await bundle.generate({ const es = await bundle.generate({
format: 'es', format: 'es',
name: 'hotkeys', name: 'hotkeys',
banner: banner.multibanner(), banner: multibanner(),
}); });
write('dist/hotkeys.js', umd.output[0].code) write('dist/hotkeys.js', umd.output[0].code)

@ -1,17 +1,18 @@
const path = require('path');
const rollup = require('rollup'); import { nodeResolve } from '@rollup/plugin-node-resolve';
const babel = require('@rollup/plugin-babel'); import commonjs from '@rollup/plugin-commonjs';
const nodeResolve = require('@rollup/plugin-node-resolve'); import path from 'path';
const commonjs = require('@rollup/plugin-commonjs'); import { watch } from 'rollup';
const banner = require('bannerjs'); import { multibanner } from 'bannerjs';
require('colors-cli/toxic'); import { babel } from '@rollup/plugin-babel';
import 'colors-cli/toxic';
const watchOptions = { const watchOptions = {
input: 'src/index.js', input: 'src/index.js',
plugins: [ plugins: [
nodeResolve.default(), // so Rollup can find `ms` nodeResolve(), // so Rollup can find `ms`
commonjs(), // so Rollup can convert `ms` to an ES module commonjs(), // so Rollup can convert `ms` to an ES module
babel.default({ babel({
babelHelpers: 'bundled', babelHelpers: 'bundled',
exclude: 'node_modules/**', // 只编译我们的源代码 exclude: 'node_modules/**', // 只编译我们的源代码
presets: [[ presets: [[
@ -30,24 +31,24 @@ const watchOptions = {
file: 'dist/hotkeys.common.js', file: 'dist/hotkeys.common.js',
name: 'hotkeys', name: 'hotkeys',
exports: 'auto', exports: 'auto',
banner: banner.multibanner(), banner: multibanner(),
format: 'cjs', format: 'cjs',
}, },
{ {
file: 'dist/hotkeys.js', file: 'dist/hotkeys.js',
name: 'hotkeys', name: 'hotkeys',
banner: banner.multibanner(), banner: multibanner(),
format: 'umd', format: 'umd',
}, },
{ {
file: 'dist/hotkeys.esm.js', file: 'dist/hotkeys.esm.js',
name: 'hotkeys', name: 'hotkeys',
banner: banner.multibanner(), banner: multibanner(),
format: 'es', format: 'es',
}, },
], ],
}; };
const watcher = rollup.watch(watchOptions); const watcher = watch(watchOptions);
watcher.on('event', (event) => { watcher.on('event', (event) => {
if (event.code === 'FATAL') { if (event.code === 'FATAL') {
Loading…
Cancel
Save