Skip to content

Commit

Permalink
refactor: 打包速度提升 58%
Browse files Browse the repository at this point in the history
  • Loading branch information
monako97 committed Oct 24, 2023
1 parent 75732d4 commit e7858e8
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 51 deletions.
34 changes: 24 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## Last

### 🐛 Bug Fixes

- replaceChildren polyfill ([75732d4](https://github.com/monako97/neko-ui/commit/75732d4770e2c5a00037338f43dd931b14f970da))

### 📚 Documentation

- polyfill ([0405059](https://github.com/monako97/neko-ui/commit/04050596a224305deb841ed1c673bce1a5e4705c))

## [2.5.1](https://github.com/monako97/neko-ui/compare/2.5.0...2.5.1) (10-12-2023)

### 📦 Code Refactoring

-@swc/helpers 作为依赖 ([b6d96a5](https://github.com/monako97/neko-ui/commit/b6d96a569d0788da680291e6bc618549831fc2a0))

### 📚 Documentation

- update readme ([428dcc5](https://github.com/monako97/neko-ui/commit/428dcc5c67aa319629569409d32adfca34436c18))
Expand Down Expand Up @@ -333,7 +347,7 @@
- 1、Carousel. 2、Photo ([ef41800](https://github.com/monako97/neko-ui/commit/ef418003258ee09da52ab71096b54cefa72ce2c5))
- 样式表按需引入、优化取色板性能 ([65c2008](https://github.com/monako97/neko-ui/commit/65c200831569e93f804c76a6b3d7e0007b616508))
- passiveSupported ([397ef3b](https://github.com/monako97/neko-ui/commit/397ef3bc1951a65472216b0fd5e46f4e5d833a07))
- 取色板支持 cmyk ([c2719e7](https://github.com/monako97/neko-ui/commit/c2719e7af1822cee8ec0a2a3be99960371bc4a04))
- 取色板支持 cmyk ([c2719e7](https://github.com/monako97/neko-ui/commit/c2719e7af1822cee8ec0a2a3be99960371bc4a04))
- common按需 ([b21343d](https://github.com/monako97/neko-ui/commit/b21343de3ab6df865f000f4412f246b718bcea2e))
- color-schema ([921edfd](https://github.com/monako97/neko-ui/commit/921edfd1bcf5a94b5110ac55efe004c1e09be0fa))

Expand Down Expand Up @@ -383,12 +397,12 @@

### 🚨 Tests

- ([c0bcf3a](https://github.com/monako97/neko-ui/commit/c0bcf3ad4bc61a0db6e864a4b17237d5cb48bfd9))
- ([27939ed](https://github.com/monako97/neko-ui/commit/27939ed817997c930963dec72085eab7ee9edae2))
- ([cbbff61](https://github.com/monako97/neko-ui/commit/cbbff614ccf04255c9bb66379ba93be514565674))
- ([0c3d1af](https://github.com/monako97/neko-ui/commit/0c3d1af21c3f14c22e2394845a03a76a6ff4d18c))
- ([f35688f](https://github.com/monako97/neko-ui/commit/f35688fed7a937de197f22d988b2f05d740318af))
- ([57f6a5f](https://github.com/monako97/neko-ui/commit/57f6a5ff0e9bf2c2541f24192e83e81d583cea17))
- ([c0bcf3a](https://github.com/monako97/neko-ui/commit/c0bcf3ad4bc61a0db6e864a4b17237d5cb48bfd9))
- ([27939ed](https://github.com/monako97/neko-ui/commit/27939ed817997c930963dec72085eab7ee9edae2))
- ([cbbff61](https://github.com/monako97/neko-ui/commit/cbbff614ccf04255c9bb66379ba93be514565674))
- ([0c3d1af](https://github.com/monako97/neko-ui/commit/0c3d1af21c3f14c22e2394845a03a76a6ff4d18c))
- ([f35688f](https://github.com/monako97/neko-ui/commit/f35688fed7a937de197f22d988b2f05d740318af))
- ([57f6a5f](https://github.com/monako97/neko-ui/commit/57f6a5ff0e9bf2c2541f24192e83e81d583cea17))

## [1.0.27](https://github.com/monako97/neko-ui/compare/1.0.22...1.0.27) (11-10-2022)

Expand All @@ -408,8 +422,8 @@

### 🚨 Tests

- ([4b505ff](https://github.com/monako97/neko-ui/commit/4b505ffd569361c6ea2b70c6328f1f6bf90fa0f6))
- ([ff828cf](https://github.com/monako97/neko-ui/commit/ff828cf378d54a9f8244b892cbbbbc7c86d23d61))
- ([4b505ff](https://github.com/monako97/neko-ui/commit/4b505ffd569361c6ea2b70c6328f1f6bf90fa0f6))
- ([ff828cf](https://github.com/monako97/neko-ui/commit/ff828cf378d54a9f8244b892cbbbbc7c86d23d61))

### 🐛 Bug Fixes

Expand Down Expand Up @@ -465,4 +479,4 @@

- lint ([2a033a7](https://github.com/monako97/neko-ui/commit/2a033a7c3dd926ddeb8d1ecb76887a2cfc8c1993))

## 0.1.0
## 0.1.0
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
[size-tag]: https://packagephobia.com/badge?p=neko-ui@latest
[size-url]: https://packagephobia.com/result?p=neko-ui@latest
[download-tag]: https://img.shields.io/npm/dm/neko-ui.svg?logo=docusign
[x-tag]: https://img.shields.io/twitter/follow/moneko97.svg?style=social

# Neko UI

Expand All @@ -25,6 +26,7 @@
[![version][version-tag]][npm-url]
[![install size][size-tag]][size-url]
[![download][download-tag]][npm-url]
![x][x-tag]

[![neko-ui][install-tag]][npm-url]

Expand Down
2 changes: 1 addition & 1 deletion components/switch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { CustomElement } from '..';
export interface SwitchProps {
/** 自定义类名 */
class?: string;
/** 自定义类名 */
/** 自定义样式表 */
css?: string;
/** 值 */
checked?: boolean;
Expand Down
84 changes: 48 additions & 36 deletions config/index.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
import type { ConfigType } from '@moneko/core';
import type { ConfigType, HtmlWebpackOption } from '@moneko/core';

const tags: HtmlWebpackOption['tags'] = [
{
tag: 'script',
textContent: `function replaceChildrenPolyfill() {
for (var l = arguments.length, newChildren = new Array(l), k = 0; k < l; k++) {
newChildren[k] = arguments[k];
}
var self = this;
while (self.firstChild) {
self.removeChild(self.firstChild);
}
newChildren.forEach(function (child) {
if (typeof child === 'string') {
self.appendChild(document.createTextNode(child));
} else {
self.appendChild(child);
}
});
}
if (!Element.prototype.replaceChildren) {
Element.prototype.replaceChildren = replaceChildrenPolyfill;
}
if (!ShadowRoot.prototype.replaceChildren) {
ShadowRoot.prototype.replaceChildren = replaceChildrenPolyfill;
}`,
},
];

const conf: Partial<ConfigType> = {
htmlPluginOption: {
favicon: './site/assets/images/favicon.ico',
tags: [
{
tag: 'script',
textContent: `function replaceChildrenPolyfill() {
for (var _len = arguments.length, newChildren = new Array(_len), _key = 0; _key < _len; _key++) {
newChildren[_key] = arguments[_key];
}
var _this = this;
while (this.firstChild) {
this.removeChild(this.firstChild);
}
newChildren.forEach(function (child) {
if (typeof child === 'string') {
_this.appendChild(document.createTextNode(child));
} else {
_this.appendChild(child);
}
});
}
if (!Element.prototype.replaceChildren) {
Element.prototype.replaceChildren = replaceChildrenPolyfill;
}
if (!ShadowRoot.prototype.replaceChildren) {
ShadowRoot.prototype.replaceChildren = replaceChildrenPolyfill;
}`,
},
{
tag: 'script',
src: 'https://cdn.statically.io/gh/monako97/cdn/main/npm/n-katex/1.0.8/umd/index.js',
},
{
tag: 'script',
src: 'https://cdn.statically.io/gh/monako97/cdn/main/npm/n-code-live/1.0.7/umd/index.js',
},
],
tags,
},
entry: {
'n-katex': 'n-katex',
'n-code-live': 'n-code-live',
},
polyfill: true,
fallbackCompPath: '@/components/fallback',
Expand Down Expand Up @@ -69,6 +67,20 @@ if (process.env.NODE_ENV === 'production') {
},
},
];
conf.entry = void 0;
conf.htmlPluginOption = {
...conf.htmlPluginOption,
tags: tags.concat([
{
tag: 'script',
src: 'https://cdn.statically.io/gh/monako97/cdn/main/npm/n-katex/1.0.8/umd/index.js',
},
{
tag: 'script',
src: 'https://cdn.statically.io/gh/monako97/cdn/main/npm/n-code-live/1.0.7/umd/index.js',
},
]),
};
}

export default conf;
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"devDependencies": {
"@commitlint/cli": "17.7.1",
"@commitlint/config-conventional": "17.7.0",
"@moneko/cli": "2.2.1",
"@moneko/core": "3.1.1",
"@moneko/cli": "2.2.2",
"@moneko/core": "3.1.3",
"@moneko/postcss": "1.0.30",
"@moneko/solid": "1.2.1",
"@solidjs/testing-library": "0.8.4",
Expand Down Expand Up @@ -66,7 +66,7 @@
"dayjs": "1.11.10",
"marked-completed": "1.2.10",
"solid-element": "1.8.0",
"solid-js": "1.8.1"
"solid-js": "1.8.3"
},
"files": [
"es",
Expand All @@ -76,6 +76,6 @@
"LICENSE"
],
"browserslist": [
"Chrome >=70"
"Chrome >=86"
]
}

0 comments on commit e7858e8

Please sign in to comment.