Skip to content

Commit 9c67d19

Browse files
authored
Merge pull request #6 from tolking/dev
chore: add rollup to build
2 parents a0a9ed8 + ccc217e commit 9c67d19

File tree

8 files changed

+62
-9
lines changed

8 files changed

+62
-9
lines changed

.browserslistrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
last 2 versions and > 2%
2+
not ie <= 8

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
node_modules/
44
dist/
5+
lib/
56

67
npm-debug.log
78
yarn-error.log

.npmignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
.editorconfig
55
.eslintrc.js
66
.prettierrc
7+
.browserslistrc
78

89
node_modules/
910
test/
1011
docs/
12+
dist/
1113
example/
1214
src/
1315

@@ -17,4 +19,6 @@ yarn.lock
1719
package-lock.json
1820
*.test.js
1921
.travis.yml
20-
tsconfig.json
22+
tsconfig.json
23+
babel.config.js
24+
rollup.config.js

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ['@babel/preset-env', '@babel/preset-typescript'],
3+
}

package.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "vue-lazy-loading",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "a vue plugin to better supporting lazy loading for image and iframe",
5-
"main": "dist/index.js",
6-
"type": "module",
7-
"types": "dist/index.d.ts",
5+
"main": "lib/index.js",
6+
"browser": "lib/index.esm.js",
7+
"module": "lib/index.esm.js",
8+
"types": "lib/index.d.ts",
89
"scripts": {
910
"dev": "tsc -w",
10-
"build": "tsc -b"
11+
"build": "cross-env NODE_ENV=production&& rollup -c rollup.config.js"
1112
},
1213
"repository": {
1314
"type": "git",
@@ -28,7 +29,14 @@
2829
},
2930
"homepage": "https://github.com/tolking/vue-lazy-loading#readme",
3031
"devDependencies": {
32+
"@babel/core": "^7.12.10",
33+
"@babel/preset-env": "^7.12.11",
34+
"@babel/preset-typescript": "^7.12.7",
3135
"@types/node": "^14.0.14",
32-
"typescript": "^3.9.5"
36+
"cross-env": "^7.0.3",
37+
"rollup": "^2.35.1",
38+
"rollup-plugin-babel": "^4.4.0",
39+
"rollup-plugin-typescript2": "^0.29.0",
40+
"typescript": "^4.1.3"
3341
}
3442
}

rollup.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import ts from 'rollup-plugin-typescript2'
2+
import babel from 'rollup-plugin-babel'
3+
4+
const commonConf = {
5+
input: './src/index.ts',
6+
plugins:[
7+
ts({
8+
extensions: ['.ts'],
9+
tsconfig: './tsconfig.json',
10+
}),
11+
babel({
12+
exclude: 'node_modules/**',
13+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
14+
}),
15+
]
16+
}
17+
18+
const list = [
19+
{
20+
file: 'lib/index.esm.js',
21+
format: 'es',
22+
exports: 'named',
23+
},
24+
{
25+
file: 'lib/index.js',
26+
format: 'umd',
27+
exports: 'named',
28+
name: 'VueLazyLoading',
29+
compact: true,
30+
},
31+
]
32+
33+
const buildConf = options => Object.assign({}, commonConf, options)
34+
35+
export default list.map(output => buildConf({ output }))

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class LazyCore {
1919
this.setObserver()
2020
} else {
2121
this.type = 'none'
22-
error('Your browser does not support IntersectionObserver. https://github.com/tolking/vue-lazy-loading#Browser Support')
22+
error('Your browser does not support IntersectionObserver. https://github.com/tolking/vue-lazy-loading#Browser-Support')
2323
}
2424
}
2525

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ES5",
4-
"module":"ES2015",
4+
"module":"ESNext",
55
"lib": ["ESNext", "DOM"],
66
"outDir": "dist",
77
"strict": true,

0 commit comments

Comments
 (0)