Skip to content

Commit daff1f1

Browse files
committed
build: named exports for cjs and grouped rollup deps
1 parent eafcd8f commit daff1f1

11 files changed

+9975
-4447
lines changed

package-lock.json

+9,862-4,047
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
"node": ">=14.0.0"
3636
},
3737
"devDependencies": {
38+
"@babel/core": "^7.19.3",
39+
"@babel/preset-env": "^7.19.4",
40+
"@babel/preset-typescript": "^7.18.6",
41+
"@rollup/plugin-alias": "^4.0.2",
42+
"@rollup/plugin-babel": "^6.0.2",
43+
"@rollup/plugin-commonjs": "^23.0.2",
44+
"@rollup/plugin-node-resolve": "^15.0.1",
45+
"@rollup/plugin-replace": "^5.0.1",
3846
"@commitlint/cli": "^17.1.2",
3947
"@commitlint/config-angular": "^17.1.0",
4048
"@commitlint/config-conventional": "^17.1.0",
@@ -48,6 +56,9 @@
4856
"lerna": "^6.0.1",
4957
"nx": "^15.0.0",
5058
"rimraf": "^3.0.2",
59+
"rollup": "^3.2.3",
60+
"rollup-plugin-postcss": "^4.0.2",
61+
"rollup-plugin-vue": "^6.0.0-beta.11",
5162
"typescript": "4.8.4"
5263
},
5364
"scripts": {

packages/basic/package.json

-11
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,12 @@
4545
"test:coverage": "cross-env NODE_ENV=test jest --config ./test/jest.config.js --coverage"
4646
},
4747
"devDependencies": {
48-
"@babel/core": "^7.19.3",
49-
"@babel/preset-env": "^7.19.4",
50-
"@babel/preset-typescript": "^7.18.6",
51-
"@rollup/plugin-babel": "^6.0.0",
52-
"@rollup/plugin-commonjs": "^23.0.0",
53-
"@rollup/plugin-node-resolve": "^15.0.0",
54-
"@rollup/plugin-replace": "^5.0.0",
5548
"@types/jest": "^29.2.0",
5649
"@types/md5": "^2.3.2",
5750
"@vue-layout/core": "^0.1.3",
5851
"@vue-layout/hyperscript": "^0.1.4",
5952
"cross-env": "^7.0.3",
6053
"jest": "^29.2.1",
61-
"rollup": "^3.2.3",
62-
"rollup-plugin-postcss": "^4.0.2",
63-
"rollup-plugin-terser": "^7.0.2",
64-
"rollup-plugin-vue": "^6.0.0-beta.11",
6554
"ts-jest": "^29.0.3",
6655
"vue": "^3.2.41",
6756
"vue-router": "^4.1.4",

packages/basic/rollup.config.mjs

+8-122
Original file line numberDiff line numberDiff line change
@@ -5,128 +5,14 @@
55
* view the LICENSE file that was distributed with this source code.
66
*/
77

8-
import vue from 'rollup-plugin-vue';
9-
import commonjs from '@rollup/plugin-commonjs';
10-
import resolve from '@rollup/plugin-node-resolve';
11-
import replace from '@rollup/plugin-replace';
12-
import babel from '@rollup/plugin-babel';
13-
import { terser } from 'rollup-plugin-terser';
14-
import postcss from 'rollup-plugin-postcss';
8+
import { readFileSync } from 'fs';
159

16-
import pkg from './package.json' assert { type: 'json' };
10+
import { createConfig } from '../../rollup.config.mjs';
1711

18-
function buildConfig(config) {
19-
return {
20-
input: 'src/entry.ts',
21-
...config,
22-
plugins: [
23-
replace({
24-
'process.env.NODE_ENV': JSON.stringify('production'),
25-
preventAssignment: true,
26-
}),
27-
postcss({
28-
extract: true,
29-
}),
30-
vue(),
31-
resolve({
32-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
33-
}),
34-
commonjs(),
35-
babel({
36-
exclude: 'node_modules/**',
37-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
38-
babelHelpers: 'bundled',
39-
}),
40-
...(config.plugins ? config.plugins : []),
41-
],
42-
43-
};
44-
}
45-
46-
// ESM/UMD/IIFE shared settings: externals
47-
// Refer to https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
48-
const external = [
49-
'@vue-layout/core',
50-
'@vue-layout/hyperscript',
51-
'smob',
52-
'vue',
53-
'vue-router',
54-
];
55-
56-
// UMD/IIFE shared settings: output.globals
57-
// Refer to https://rollupjs.org/guide/en#output-globals for details
58-
const globals = {
59-
vue: 'Vue',
60-
'vue-router': 'VueRouter',
61-
};
62-
63-
const name = 'VueLayoutNavigation';
64-
65-
export default [
66-
buildConfig({
67-
input: 'src/index.ts',
68-
external,
69-
output: [
70-
{
71-
file: pkg.module,
72-
format: 'esm',
73-
exports: 'named',
74-
assetFileNames: '[name]-[hash][extname]',
75-
},
76-
],
77-
}),
78-
buildConfig({
79-
external,
80-
output: [
81-
{
82-
compact: true,
83-
file: pkg.main,
84-
format: 'cjs',
85-
exports: 'auto',
86-
assetFileNames: '[name]-[hash][extname]',
87-
globals,
88-
},
89-
],
90-
}),
91-
buildConfig({
92-
input: 'src/index.ts',
93-
external,
94-
plugins: [
95-
terser({
96-
output: {
97-
ecma: 5,
98-
},
99-
}),
100-
],
101-
output: [
102-
{
103-
name,
104-
compact: true,
105-
file: pkg.browser,
106-
format: 'esm',
107-
assetFileNames: '[name]-[hash][extname]',
108-
globals,
109-
},
110-
],
12+
export default {
13+
...createConfig({
14+
pkg: JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')),
15+
vuePlugin: true
11116
}),
112-
buildConfig({
113-
external,
114-
plugins: [
115-
terser({
116-
output: {
117-
ecma: 5,
118-
},
119-
}),
120-
],
121-
output: [
122-
{
123-
name,
124-
compact: true,
125-
file: pkg.unpkg,
126-
format: 'iife',
127-
assetFileNames: '[name]-[hash][extname]',
128-
globals,
129-
},
130-
],
131-
}),
132-
];
17+
input: 'src/index.ts'
18+
};

packages/basic/src/entry.ts

-25
This file was deleted.

packages/core/package.json

-10
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@
3131
"lint:fix": "npm run lint -- --fix"
3232
},
3333
"devDependencies": {
34-
"@babel/core": "^7.19.3",
35-
"@babel/preset-env": "^7.19.4",
36-
"@babel/preset-typescript": "^7.18.6",
37-
"@rollup/plugin-alias": "^4.0.0",
38-
"@rollup/plugin-babel": "^6.0.0",
39-
"@rollup/plugin-commonjs": "^23.0.0",
40-
"@rollup/plugin-node-resolve": "^15.0.0",
41-
"@rollup/plugin-replace": "^5.0.0",
42-
"rollup": "^3.2.3",
43-
"rollup-plugin-terser": "^7.0.2",
4434
"smob": "^0.0.6",
4535
"vue": "^3.2.41"
4636
},

packages/core/rollup.config.mjs

+8-99
Original file line numberDiff line numberDiff line change
@@ -5,104 +5,13 @@
55
* view the LICENSE file that was distributed with this source code.
66
*/
77

8-
import commonjs from '@rollup/plugin-commonjs';
9-
import resolve from '@rollup/plugin-node-resolve';
10-
import babel from '@rollup/plugin-babel';
11-
import { terser } from 'rollup-plugin-terser';
12-
import pkg from './package.json' assert { type: 'json' };
8+
import { readFileSync } from 'fs';
139

14-
const extensions = [
15-
'.js', '.jsx', '.ts', '.tsx',
16-
];
10+
import { createConfig } from '../../rollup.config.mjs';
1711

18-
const name = 'VueLayoutCore';
19-
const external = [
20-
'smob',
21-
'vue',
22-
];
23-
24-
export default [
25-
{
26-
input: './src/index.ts',
27-
28-
// Specify here external modules which you don't want to include in your bundle (for instance: 'lodash', 'moment' etc.)
29-
// https://rollupjs.org/guide/en/#external
30-
external,
31-
32-
plugins: [
33-
// Allows node_modules resolution
34-
resolve({ extensions }),
35-
36-
// Allow bundling cjs modules. Rollup doesn't understand cjs
37-
commonjs(),
38-
39-
// Compile TypeScript/JavaScript files
40-
babel({
41-
extensions,
42-
babelHelpers: 'bundled',
43-
include: [
44-
'src/**/*',
45-
],
46-
}),
47-
terser({
48-
output: {
49-
ecma: 5,
50-
},
51-
}),
52-
],
53-
output: [
54-
{
55-
file: pkg.main,
56-
format: 'cjs',
57-
}, {
58-
file: pkg.module,
59-
format: 'esm',
60-
},
61-
],
62-
},
63-
{
64-
input: './src/index.ts',
65-
66-
// Specify here external modules which you don't want to include in your bundle (for instance: 'lodash', 'moment' etc.)
67-
// https://rollupjs.org/guide/en/#external
68-
external,
69-
70-
plugins: [
71-
// Allows node_modules resolution
72-
resolve({ extensions }),
73-
74-
// Allow bundling cjs modules. Rollup doesn't understand cjs
75-
commonjs(),
76-
77-
// Compile TypeScript/JavaScript files
78-
babel({
79-
extensions,
80-
babelHelpers: 'bundled',
81-
include: [
82-
'src/**/*',
83-
],
84-
}),
85-
terser({
86-
output: {
87-
ecma: 5,
88-
},
89-
}),
90-
],
91-
output: [
92-
{
93-
file: pkg.browser,
94-
format: 'esm',
95-
},
96-
{
97-
file: pkg.unpkg,
98-
format: 'iife',
99-
name,
100-
101-
// https://rollupjs.org/guide/en/#outputglobals
102-
globals: {
103-
104-
},
105-
},
106-
],
107-
},
108-
];
12+
export default {
13+
...createConfig({
14+
pkg: JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
15+
}),
16+
input: 'src/index.ts'
17+
};

packages/hyperscript/package.json

-14
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,8 @@
3838
"lint:fix": "npm run lint -- --fix"
3939
},
4040
"devDependencies": {
41-
"@babel/core": "^7.19.3",
42-
"@babel/preset-env": "^7.19.4",
43-
"@babel/preset-typescript": "^7.18.6",
44-
"@rollup/plugin-alias": "^4.0.0",
45-
"@rollup/plugin-babel": "^6.0.0",
46-
"@rollup/plugin-commonjs": "^23.0.0",
47-
"@rollup/plugin-node-resolve": "^15.0.0",
48-
"@rollup/plugin-replace": "^5.0.0",
4941
"@vue-layout/core": "^0.1.3",
5042
"cross-env": "^7.0.3",
51-
"rollup": "^3.2.3",
52-
"rollup-plugin-includepaths": "^0.2.4",
53-
"rollup-plugin-postcss": "^4.0.2",
54-
"rollup-plugin-styles": "^4.0.0",
55-
"rollup-plugin-terser": "^7.0.2",
56-
"rollup-plugin-vue": "^6.0.0-beta.11",
5743
"vue": "^3.2.41"
5844
},
5945
"peerDependencies": {

0 commit comments

Comments
 (0)