mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
docs:更新文档
This commit is contained in:
20
node_modules/rollup-plugin-terser/LICENSE
generated
vendored
Normal file
20
node_modules/rollup-plugin-terser/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2018 Bogdan Chadkin <trysound@yandex.ru>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
106
node_modules/rollup-plugin-terser/README.md
generated
vendored
Normal file
106
node_modules/rollup-plugin-terser/README.md
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
# rollup-plugin-terser [![Travis Build Status][travis-img]][travis]
|
||||
|
||||
[travis-img]: https://travis-ci.org/TrySound/rollup-plugin-terser.svg
|
||||
[travis]: https://travis-ci.org/TrySound/rollup-plugin-terser
|
||||
|
||||
[Rollup](https://github.com/rollup/rollup) plugin to minify generated es bundle. Uses [terser](https://github.com/fabiosantoscode/terser) under the hood.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
yarn add rollup-plugin-terser --dev
|
||||
# Or with npm:
|
||||
npm i rollup-plugin-terser --save-dev
|
||||
```
|
||||
|
||||
_Note: this package requires rollup@0.66 and higher (including rollup@2.0.0)_
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { rollup } from "rollup";
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
|
||||
rollup({
|
||||
input: "main.js",
|
||||
plugins: [terser()],
|
||||
});
|
||||
```
|
||||
|
||||
## Why named export?
|
||||
|
||||
1. Module is a namespace. Default export often leads to function/component per file dogma and makes code less maintainable.
|
||||
2. Interop with commonjs is broken in many cases or hard to maintain.
|
||||
3. Show me any good language with default exports. It's historical javascriptism.
|
||||
|
||||
## Options
|
||||
|
||||
> ⚠️ **Caveat:** any function used in options object cannot rely on its surrounding scope, since it is executed in an isolated context.
|
||||
|
||||
```js
|
||||
terser(options);
|
||||
```
|
||||
|
||||
`options` - [terser API options](https://github.com/fabiosantoscode/terser#minify-options)
|
||||
|
||||
Note: some terser options are set by the plugin automatically:
|
||||
|
||||
- `module: true` is set when `format` is `esm` or `es`
|
||||
- `toplevel: true` is set when `format` is `cjs`
|
||||
|
||||
`options.numWorkers: number`
|
||||
|
||||
Amount of workers to spawn. Defaults to the number of CPUs minus 1.
|
||||
|
||||
## Examples
|
||||
|
||||
### Using as output plugin
|
||||
|
||||
```js
|
||||
// rollup.config.js
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
|
||||
export default {
|
||||
input: "index.js",
|
||||
output: [
|
||||
{ file: "lib.js", format: "cjs" },
|
||||
{ file: "lib.min.js", format: "cjs", plugins: [terser()] },
|
||||
{ file: "lib.esm.js", format: "esm" },
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
### Comments
|
||||
|
||||
If you'd like to preserve comments (for licensing for example), then you can specify a function to do this like so:
|
||||
|
||||
```js
|
||||
terser({
|
||||
output: {
|
||||
comments: function (node, comment) {
|
||||
var text = comment.value;
|
||||
var type = comment.type;
|
||||
if (type == "comment2") {
|
||||
// multiline comment
|
||||
return /@preserve|@license|@cc_on/i.test(text);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Alternatively, you can also choose to keep all comments (e.g. if a licensing header has already been prepended by a previous rollup plugin):
|
||||
|
||||
```js
|
||||
terser({
|
||||
output: {
|
||||
comments: "all",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
See [Terser documentation](https://github.com/fabiosantoscode/terser#terser) for further reference.
|
||||
|
||||
# License
|
||||
|
||||
MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
|
||||
85
node_modules/rollup-plugin-terser/package.json
generated
vendored
Normal file
85
node_modules/rollup-plugin-terser/package.json
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"rollup-plugin-terser@7.0.2",
|
||||
"J:\\Github\\CURD-TS"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "rollup-plugin-terser@7.0.2",
|
||||
"_id": "rollup-plugin-terser@7.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-6Pu6SGmYGy3DWufopQLVxsBNMk0=",
|
||||
"_location": "/rollup-plugin-terser",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "rollup-plugin-terser@7.0.2",
|
||||
"name": "rollup-plugin-terser",
|
||||
"escapedName": "rollup-plugin-terser",
|
||||
"rawSpec": "7.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "7.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/vite"
|
||||
],
|
||||
"_resolved": "http://192.168.250.101:4873/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz",
|
||||
"_spec": "7.0.2",
|
||||
"_where": "J:\\Github\\CURD-TS",
|
||||
"author": {
|
||||
"name": "Bogdan Chadkin",
|
||||
"email": "trysound@yandex.ru"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/TrySound/rollup-plugin-terser/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.10.4",
|
||||
"jest-worker": "^26.2.1",
|
||||
"serialize-javascript": "^4.0.0",
|
||||
"terser": "^5.0.0"
|
||||
},
|
||||
"description": "Rollup plugin to minify generated es bundle",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.11.1",
|
||||
"jest": "^26.2.2",
|
||||
"prettier": "^2.0.5",
|
||||
"rollup": "^2.23.1"
|
||||
},
|
||||
"exports": {
|
||||
"require": "./rollup-plugin-terser.js",
|
||||
"import": "./rollup-plugin-terser.mjs"
|
||||
},
|
||||
"files": [
|
||||
"rollup-plugin-terser.js",
|
||||
"rollup-plugin-terser.mjs",
|
||||
"rollup-plugin-terser.d.ts",
|
||||
"transform.js"
|
||||
],
|
||||
"homepage": "https://github.com/TrySound/rollup-plugin-terser#readme",
|
||||
"keywords": [
|
||||
"rollup",
|
||||
"rollup-plugin",
|
||||
"terser",
|
||||
"minify"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "rollup-plugin-terser.js",
|
||||
"name": "rollup-plugin-terser",
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/TrySound/rollup-plugin-terser.git"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "yarn test",
|
||||
"test": "jest"
|
||||
},
|
||||
"type": "commonjs",
|
||||
"types": "rollup-plugin-terser.d.ts",
|
||||
"version": "7.0.2"
|
||||
}
|
||||
11
node_modules/rollup-plugin-terser/rollup-plugin-terser.d.ts
generated
vendored
Normal file
11
node_modules/rollup-plugin-terser/rollup-plugin-terser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Plugin } from "rollup";
|
||||
import { MinifyOptions } from "terser";
|
||||
|
||||
export interface Options extends Omit<MinifyOptions, "sourceMap"> {
|
||||
/**
|
||||
* Amount of workers to spawn. Defaults to the number of CPUs minus 1.
|
||||
*/
|
||||
numWorkers?: number;
|
||||
}
|
||||
|
||||
export declare function terser(options?: Options): Plugin;
|
||||
102
node_modules/rollup-plugin-terser/rollup-plugin-terser.js
generated
vendored
Normal file
102
node_modules/rollup-plugin-terser/rollup-plugin-terser.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
const { codeFrameColumns } = require("@babel/code-frame");
|
||||
const Worker = require("jest-worker").default;
|
||||
const serialize = require("serialize-javascript");
|
||||
|
||||
function terser(userOptions = {}) {
|
||||
if (userOptions.sourceMap != null) {
|
||||
throw Error(
|
||||
"sourceMap option is removed. Now it is inferred from rollup options."
|
||||
);
|
||||
}
|
||||
if (userOptions.sourcemap != null) {
|
||||
throw Error(
|
||||
"sourcemap option is removed. Now it is inferred from rollup options."
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
name: "terser",
|
||||
|
||||
async renderChunk(code, chunk, outputOptions) {
|
||||
if (!this.worker) {
|
||||
this.worker = new Worker(require.resolve("./transform.js"), {
|
||||
numWorkers: userOptions.numWorkers,
|
||||
});
|
||||
this.numOfBundles = 0;
|
||||
}
|
||||
|
||||
this.numOfBundles++;
|
||||
|
||||
const defaultOptions = {
|
||||
sourceMap:
|
||||
outputOptions.sourcemap === true ||
|
||||
typeof outputOptions.sourcemap === "string",
|
||||
};
|
||||
if (outputOptions.format === "es" || outputOptions.format === "esm") {
|
||||
defaultOptions.module = true;
|
||||
}
|
||||
if (outputOptions.format === "cjs") {
|
||||
defaultOptions.toplevel = true;
|
||||
}
|
||||
|
||||
const normalizedOptions = { ...defaultOptions, ...userOptions };
|
||||
|
||||
// remove plugin specific options
|
||||
for (let key of ["numWorkers"]) {
|
||||
if (normalizedOptions.hasOwnProperty(key)) {
|
||||
delete normalizedOptions[key];
|
||||
}
|
||||
}
|
||||
|
||||
const serializedOptions = serialize(normalizedOptions);
|
||||
|
||||
try {
|
||||
const result = await this.worker.transform(code, serializedOptions);
|
||||
|
||||
if (result.nameCache) {
|
||||
let { vars, props } = userOptions.nameCache;
|
||||
|
||||
// only assign nameCache.vars if it was provided, and if terser produced values:
|
||||
if (vars) {
|
||||
const newVars =
|
||||
result.nameCache.vars && result.nameCache.vars.props;
|
||||
if (newVars) {
|
||||
vars.props = vars.props || {};
|
||||
Object.assign(vars.props, newVars);
|
||||
}
|
||||
}
|
||||
|
||||
// support populating an empty nameCache object:
|
||||
if (!props) {
|
||||
props = userOptions.nameCache.props = {};
|
||||
}
|
||||
|
||||
// merge updated props into original nameCache object:
|
||||
const newProps =
|
||||
result.nameCache.props && result.nameCache.props.props;
|
||||
if (newProps) {
|
||||
props.props = props.props || {};
|
||||
Object.assign(props.props, newProps);
|
||||
}
|
||||
}
|
||||
|
||||
return result.result;
|
||||
} catch (error) {
|
||||
const { message, line, col: column } = error;
|
||||
console.error(
|
||||
codeFrameColumns(code, { start: { line, column } }, { message })
|
||||
);
|
||||
throw error;
|
||||
} finally {
|
||||
this.numOfBundles--;
|
||||
|
||||
if (this.numOfBundles === 0) {
|
||||
this.worker.end();
|
||||
this.worker = 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
exports.terser = terser;
|
||||
3
node_modules/rollup-plugin-terser/rollup-plugin-terser.mjs
generated
vendored
Normal file
3
node_modules/rollup-plugin-terser/rollup-plugin-terser.mjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import terserModule from "./rollup-plugin-terser.js";
|
||||
|
||||
export const terser = terserModule.terser;
|
||||
8
node_modules/rollup-plugin-terser/transform.js
generated
vendored
Normal file
8
node_modules/rollup-plugin-terser/transform.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
const { minify } = require("terser");
|
||||
|
||||
const transform = (code, optionsString) => {
|
||||
const options = eval(`(${optionsString})`);
|
||||
return minify(code, options).then(result => ({ result, nameCache: options.nameCache }));
|
||||
};
|
||||
|
||||
exports.transform = transform;
|
||||
Reference in New Issue
Block a user