Skip to content

Commit 3c303f9

Browse files
author
lixiangfei
committed
feat: add files
1 parent e125ac7 commit 3c303f9

31 files changed

+10653
-0
lines changed

.babelrc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"chrome": "65",
8+
"ie": "11"
9+
},
10+
"modules":false
11+
}
12+
]
13+
],
14+
"plugins": [
15+
["@babel/plugin-transform-runtime",
16+
{
17+
"regenerator": true
18+
}
19+
]
20+
]
21+
}

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/**
2+
es/**
3+
lib/**

.eslintrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
3+
extends:['./eslint/base.js',],
4+
parserOptions: {
5+
"ecmaVersion": 2019,
6+
"sourceType": 'module',
7+
"allowImportExportEverywhere": true,
8+
"ecmaFeatures":{
9+
jsx:true
10+
},
11+
},
12+
env:{
13+
browser: true,
14+
node: true,
15+
es6: true
16+
}
17+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.prettierrc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
"printWidth": 120,
3+
"semi": false,
4+
"singleQuote": true,
5+
"trailingComma": "all",
6+
"bracketSpacing": false,
7+
"jsxBracketSameLine": true,
8+
"arrowParens": "avoid",
9+
"insertPragma": true,
10+
"tabWidth": 4,
11+
"useTabs": false
12+
};

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# npm-template
2+
template for npm package
3+
npm发包模版,可基于模块快速建立npm发包项目
4+
5+
# content
6+
1. rollup打包, 支持js,json, css,scss,worker
7+
2. babel 环境采用@babel/env,支持async打包
8+
3. 集成eslint以及prettierrc配置

config/rollup.base.config.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const { uglify } = require('rollup-plugin-uglify');
2+
const json = require('rollup-plugin-json');
3+
const postcss = require('rollup-plugin-postcss');
4+
const babel = require('rollup-plugin-babel');
5+
const resolve = require('rollup-plugin-node-resolve');
6+
const commonjs = require('rollup-plugin-commonjs');
7+
const { string } = require('rollup-plugin-string');
8+
const context = require('rollup-plugin-require-context');
9+
const builtins = require('rollup-plugin-node-builtins');
10+
const bundleWorker = require('../libs/worker');
11+
const analyzer = require('rollup-plugin-visualizer');
12+
13+
const defaultRollup = {
14+
input: 'src/index.js',
15+
name: 'Player',
16+
sourcemap: true,
17+
production: false,
18+
external: [],
19+
plugins: [],
20+
globals: {},
21+
commonjs: {},
22+
resolve: {},
23+
babel: {},
24+
watch: {}
25+
};
26+
27+
const commonRollup = function (config = {}) {
28+
const rollupConfig = Object.assign({}, defaultRollup, config);
29+
return {
30+
input: rollupConfig.input,
31+
output: config.output || [
32+
{
33+
file: rollupConfig.uglify ? 'dist/index.min.js' : 'dist/index.js',
34+
name: rollupConfig.name,
35+
format: 'umd',
36+
sourcemap: uglify ? false : rollupConfig.sourcemap,
37+
globals: rollupConfig.globals
38+
}
39+
],
40+
external: rollupConfig.external,
41+
plugins: [
42+
...rollupConfig.plugins,
43+
bundleWorker(),
44+
rollupConfig.uglify ? uglify(rollupConfig.uglify) : undefined,
45+
json({
46+
compact: true
47+
}),
48+
postcss({
49+
extensions: ['.css', '.scss', '.sass'],
50+
'postcss-cssnext': {
51+
browserslist: ['cover 99.5%']
52+
}
53+
}),
54+
babel({
55+
exclude: ['node_modules/**', '**/*.svg'],
56+
...rollupConfig.babel
57+
}),
58+
resolve({
59+
preferBuiltins: true,
60+
extensions: ['.mjs', '.js', '.jsx', '.json'],
61+
...rollupConfig.resolve
62+
}),
63+
string({
64+
include: '**/*.svg'
65+
}),
66+
commonjs({
67+
include: [/node_modules/],
68+
...rollupConfig.commonjs
69+
}),
70+
builtins(),
71+
context(),
72+
process.env.ANALYZE ? analyzer() : undefined
73+
],
74+
watch: {
75+
...config.watch
76+
}
77+
};
78+
};
79+
module.exports = commonRollup;

dist/index.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

es/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import _ProxyPromise from './proxyPromise';
2+
import _SpeedSampler from './speedSampler';
3+
import _XmlUtils from './xmlutils';
4+
import _Utils from './utils';
5+
import _Xml2Json from './xml2json';
6+
export { isSupportRawCryptoCTR } from './rawCryptoCheck';
7+
export var ProxyPromise = _ProxyPromise;
8+
export var Speedsampler = _SpeedSampler;
9+
export var XmlUtils = _XmlUtils;
10+
export var Utils = _Utils;
11+
export var Xml2Json = _Xml2Json;

es/proxyPromise.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2+
import _createClass from "@babel/runtime/helpers/createClass";
3+
4+
/* eslint-disable no-empty-function */
5+
var ProxyPromise = /*#__PURE__*/function () {
6+
function ProxyPromise() {
7+
_classCallCheck(this, ProxyPromise);
8+
9+
var resolvePromise;
10+
var rejectPromise;
11+
var promise = new Promise(function (resolve, reject) {
12+
resolvePromise = resolve;
13+
rejectPromise = reject;
14+
});
15+
var publicPromise = promise;
16+
publicPromise.resolve = resolvePromise;
17+
publicPromise.reject = rejectPromise;
18+
return publicPromise;
19+
}
20+
/** @param {T=} value */
21+
22+
23+
_createClass(ProxyPromise, [{
24+
key: "resolve",
25+
value: function resolve(value) {}
26+
/** @param {*=} reason */
27+
28+
}, {
29+
key: "reject",
30+
value: function reject(reason) {}
31+
}]);
32+
33+
return ProxyPromise;
34+
}();
35+
36+
export { ProxyPromise as default };

0 commit comments

Comments
 (0)