Skip to content

Commit f2c00c6

Browse files
committed
fix: build es module
1 parent 3a364c6 commit f2c00c6

14 files changed

+493
-9
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist
2-
lib/rs.js
2+
lib
3+
build

build/rollup.config.base.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// rollup.config.base.js
2+
import resovle from 'rollup-plugin-node-resolve';
3+
import commonjs from 'rollup-plugin-commonjs';
4+
import typescript from 'rollup-plugin-typescript';
5+
import strip from 'rollup-plugin-strip';
6+
import { terser } from 'rollup-plugin-terser';
7+
8+
export default (config) => ({
9+
input: 'src/index.ts',
10+
output: {
11+
file: config.file,
12+
format: config.format,
13+
name: 'rs'
14+
},
15+
plugins: [
16+
resovle(),
17+
commonjs(),
18+
typescript(),
19+
terser(),
20+
strip({
21+
debugger: true,
22+
functions: ['console.log', 'assert.*', 'debug', 'alert'],
23+
sourceMap: false
24+
})
25+
],
26+
external: ['loadsh', 'jquery']
27+
});

build/rollup.config.cjs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import path from 'path';
2+
import rollupConfig from './rollup.config.base';
3+
4+
const resovleFile = (filePath) => path.join(__dirname, '..', filePath);
5+
6+
export default rollupConfig({
7+
file: resovleFile('lib/rs.cjs.js'),
8+
format: 'cjs'
9+
});

build/rollup.config.dev.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// rollup.config.dev.js
2+
3+
import resovle from 'rollup-plugin-node-resolve';
4+
import commonjs from 'rollup-plugin-commonjs';
5+
import typescript from 'rollup-plugin-typescript';
6+
import serve from 'rollup-plugin-serve';
7+
8+
export default {
9+
input: 'src/index.ts',
10+
output: {
11+
file: 'dist/rs.js',
12+
format: 'umd',
13+
name: 'rs'
14+
},
15+
plugins: [
16+
resovle(),
17+
commonjs(),
18+
typescript(),
19+
serve({
20+
open: true,
21+
contentBase: ['example', 'dist'],
22+
port: 3000
23+
})
24+
]
25+
};

build/rollup.config.es.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import path from 'path';
2+
import rollupConfig from './rollup.config.base';
3+
4+
const resovleFile = (filePath) => path.join(__dirname, '..', filePath);
5+
6+
export default rollupConfig({
7+
file: resovleFile('lib/rs.es.js'),
8+
format: 'es'
9+
});

build/rollup.config.iife.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import path from 'path';
2+
import rollupConfig from './rollup.config.base';
3+
4+
const resovleFile = (filePath) => path.join(__dirname, '..', filePath);
5+
6+
export default rollupConfig({
7+
file: resovleFile('lib/rs.iife.js'),
8+
format: 'iife'
9+
});

build/rollup.config.umd.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import path from 'path';
2+
import rollupConfig from './rollup.config.base';
3+
4+
const resovleFile = (filePath) => path.join(__dirname, '..', filePath);
5+
6+
export default rollupConfig({
7+
file: resovleFile('lib/rs.js'),
8+
format: 'umd'
9+
});

dist/bundle.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/rs.cjs.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.

lib/rs.es.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.

0 commit comments

Comments
 (0)