From d31ec1287bb6edacc6e86408aeaaeaafe1a2ae85 Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 25 Apr 2022 18:22:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE,=E6=94=B9?= =?UTF-8?q?=E4=B8=BAesm=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.dev.js | 32 ++++++++++++++++---------------- build.prod.js | 30 +++++++++++++++--------------- package.json | 10 ++++++++-- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/build.dev.js b/build.dev.js index 1be0801..3c71713 100644 --- a/build.dev.js +++ b/build.dev.js @@ -1,18 +1,18 @@ #! /usr/bin/env node -require('es.shim') +import 'es.shim' +import fs from 'iofs' +import { parse, resolve } from 'path' +import scss from 'sass' +import chalk from 'chalk' +import { transform } from 'esbuild' +import chokidar from 'chokidar' + +const { version } = JSON.parse(fs.cat('./package.json')) +const sourceDir = resolve('./src') +const buildDir = resolve('./dist') + const log = console.log -const fs = require('iofs') -const path = require('path') -const scss = require('sass') -const chokidar = require('chokidar') -const chalk = require('chalk') -const { transform } = require('esbuild') - -const sourceDir = path.resolve(__dirname, 'src') -const buildDir = path.resolve(__dirname, 'dist') - -const VERSION = require('./package.json').version const BUILD_DATE = new Date().format() const ESBUILD_OPTIONS = { @@ -66,7 +66,7 @@ function mkWCFile({ style, html, js }) { let name = '' - js = js.replace(/props = (\{\}|\{[\w\W]*?\n\s{2}?\})/, function(str) { + js = js.replace(/props = (\{\}|\{[\w\W]*?\n\s{2}?\})/, function (str) { var attr = str .split(/\n+/) .slice(1, -1) @@ -85,7 +85,7 @@ function mkWCFile({ style, html, js }) { }) js = fixImport(js) - .replace(/export default class ([a-zA-Z0-9]+)/, function(s, m) { + .replace(/export default class ([a-zA-Z0-9]+)/, function (s, m) { name = m return `${s} extends HTMLElement ` }) @@ -117,7 +117,7 @@ function mkWCFile({ style, html, js }) { * * @authors yutent (yutent.io@gmail.com) * @date ${BUILD_DATE} - * @version v${VERSION} + * @version v${version} * */ @@ -154,7 +154,7 @@ chokidar let entry = file let output = file.replace('src/', 'dist/') - file = path.parse(entry) + file = parse(entry) if (!file.ext || file.base === '.DS_Store' || file.base === 'var.scss') { return } diff --git a/build.prod.js b/build.prod.js index 967df9b..e9a2f7e 100644 --- a/build.prod.js +++ b/build.prod.js @@ -1,17 +1,17 @@ #! /usr/bin/env node -require('es.shim') +import 'es.shim' +import fs from 'iofs' +import { parse, resolve } from 'path' +import scss from 'sass' +import chalk from 'chalk' +import { transform } from 'esbuild' + +const { version } = JSON.parse(fs.cat('./package.json')) +const sourceDir = resolve('./src') +const buildDir = resolve('./dist') + const log = console.log -const fs = require('iofs') -const path = require('path') -const scss = require('sass') -const chalk = require('chalk') -const { transform } = require('esbuild') - -const sourceDir = path.resolve(__dirname, 'src') -const buildDir = path.resolve(__dirname, 'dist') - -const VERSION = require('./package.json').version const BUILD_DATE = new Date().format() const ESBUILD_OPTIONS = { @@ -72,7 +72,7 @@ function mkWCFile({ style, html, js }) { html = html.replace(/[\n\r]+/g, ' ') html = html.replace(/\s+/g, ' ') - js = js.replace(/props = (\{\}|\{[\w\W]*?\n\s{2}?\})/, function(str) { + js = js.replace(/props = (\{\}|\{[\w\W]*?\n\s{2}?\})/, function (str) { var attr = str .split(/\n+/) .slice(1, -1) @@ -91,7 +91,7 @@ function mkWCFile({ style, html, js }) { }) js = fixImport(js) - .replace(/export default class ([a-zA-Z0-9]+)/, function(s, m) { + .replace(/export default class ([a-zA-Z0-9]+)/, function (s, m) { name = m return `${s} extends HTMLElement ` }) @@ -124,7 +124,7 @@ function mkWCFile({ style, html, js }) { * * @authors yutent (yutent.io@gmail.com) * @date ${BUILD_DATE} - * @version v${VERSION} + * @version v${version} * */ @@ -166,7 +166,7 @@ fs.mkdir(buildDir) let files = fs.ls(sourceDir, true) files = files.map(it => { - let file = path.parse(it) + let file = parse(it) if (!file.ext || file.base === '.DS_Store' || file.base === 'var.scss') { return null } diff --git a/package.json b/package.json index f17a7b1..cf8bfc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "@bytedo/wcui", "version": "1.0.5", + "type": "module", "description": "基于wc开发的一套UI库, 面向未来, 面向electron", "scripts": { "start": "node ./build.dev.js", @@ -11,11 +12,16 @@ "url": "git+https://github.com/bytedo/wcui.git" }, "main": "dist/", - "keywords": ["web-components", "wc", "components", "yutent"], + "keywords": [ + "web-components", + "wc", + "components", + "yutent" + ], "author": "yutent", "license": "MIT", "devDependencies": { - "chalk": "^3.0.0", + "chalk": "^5.0.0", "chokidar": "^3.5.2", "es.shim": "^2.0.2", "iofs": "^1.5.2",