Skip to content

Commit 6c6a175

Browse files
committed
feat: upgrade rollup v4 and other packages
1 parent 2f5d5c2 commit 6c6a175

32 files changed

+2942
-1244
lines changed

.changeset/cold-camels-rest.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ice/pkg': major
3+
---
4+
5+
feat: upgrade rollup to v4 and other packages

.eslintignore

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,30 @@ coverage/
99
node_modules
1010
extensions/*/out
1111
.vscode-test
12-
packages/**/lib/
13-
packages/**/es/
14-
packages/**/esnext/
15-
packages/**/esm/
16-
packages/**/es2017/
17-
packages/**/cjs/
18-
packages/**/build/
12+
packages/*/lib/
13+
packages/*/es/
14+
packages/*/esnext/
15+
packages/*/esm/
16+
packages/*/es2017/
17+
packages/*/cjs/
18+
packages/*/build/
1919
packages/build-plugin-component/*/template
2020
app/main_dist/
2121
app/build/
2222
tmp
2323
.tmp
2424
__mocks__
25-
__tests__
2625

2726
# 忽略文件
2827
**/*-min.js
2928
**/*.min.js
3029

3130
lib
32-
node_modules
33-
__tests__
34-
examples/**/esm
35-
examples/**/es
36-
examples/**/es2017
37-
examples/**/cjs
38-
examples/**/lib
39-
examples/**/dist
40-
examples/**/build
31+
examples/*/esm
32+
examples/*/es
33+
examples/*/es2017
34+
examples/*/cjs
35+
examples/*/lib
36+
examples/*/dist
37+
examples/*/build
38+
examples/*/typings

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ examples/**/.vscode
4848
examples/**/.DS_Store
4949
examples/**/.docusaurus
5050
examples/**/build
51+
examples/**/typings

examples/react-component/build.config.mts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { defineConfig } from '@ice/pkg';
33
// https://pkg.ice.work/reference/config-list
44
export default defineConfig({
55
plugins: [
6-
[
7-
'@ice/pkg-plugin-docusaurus',
8-
{
9-
remarkPlugins: [
10-
"require('@ice/remark-react-docgen-docusaurus')",
11-
// "[require('remark-react-docgen'), {}]",
12-
],
13-
},
14-
],
6+
// [
7+
// '@ice/pkg-plugin-docusaurus',
8+
// {
9+
// remarkPlugins: [
10+
// "require('@ice/remark-react-docgen-docusaurus')",
11+
// // "[require('remark-react-docgen'), {}]",
12+
// ],
13+
// },
14+
// ],
1515
['@ice/pkg-plugin-jsx-plus'],
1616
],
1717
transform: {
@@ -21,7 +21,6 @@ export default defineConfig({
2121
sourceMaps: false,
2222
bundle: {
2323
formats: ['esm', 'es2017'],
24-
development: true,
2524
},
2625
alias: {
2726
'@': './src',

examples/react-component/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
},
3838
"dependencies": {
3939
"@ice/jsx-runtime": "^0.2.0",
40-
"@swc/helpers": "^0.5.1",
41-
"babel-runtime-jsx-plus": "^0.1.5"
40+
"@swc/helpers": "^0.5.13",
41+
"babel-runtime-jsx-plus": "^0.1.5",
42+
"core-js": "^3.38.1"
4243
},
4344
"devDependencies": {
4445
"@ice/pkg": "workspace:*",

packages/ice-npm-utils/__tests__/index.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ test('getUnpkgHost custom host', () => {
4040
});
4141

4242
test('getUnpkgHost', () => {
43+
// eslint-disable-next-line @typescript-eslint/no-shadow
4344
const defaultRegistry = 'https://unpkg.com';
4445

4546
expect(getUnpkgHost('koa')).toBe(defaultRegistry);
@@ -123,7 +124,7 @@ test('getNpmTarball', () => {
123124
console.log('getNpmTarball ice-npm-utils', tarball);
124125
expect(
125126
tbRegisties
126-
.some(registry => tarball === `${registry}/ice-npm-utils/-/ice-npm-utils-1.0.0.tgz`)
127+
.some((registry) => tarball === `${registry}/ice-npm-utils/-/ice-npm-utils-1.0.0.tgz`),
127128
).toBeTruthy();
128129
});
129130
});
@@ -139,7 +140,7 @@ test('getNpmTarball should get latest version', () => {
139140
console.log('getNpmTarball http', tarball);
140141
expect(
141142
tbRegisties
142-
.some(registry => tarball === `${registry}/http/-/http-0.0.1-security.tgz`)
143+
.some((registry) => tarball === `${registry}/http/-/http-0.0.1-security.tgz`),
143144
).toBeTruthy();
144145
});
145146
});
@@ -164,7 +165,7 @@ test('getAndExtractTarballWithDir', () => {
164165
const tempDir = path.resolve(tmpdir(), 'babel_helper_function_name_tarball');
165166
return getAndExtractTarball(
166167
tempDir,
167-
`${defaultRegistry}/@babel/helper-function-name/download/@babel/helper-function-name-7.1.0.tgz`
168+
`${defaultRegistry}/@babel/helper-function-name/download/@babel/helper-function-name-7.1.0.tgz`,
168169
)
169170
.then((files) => {
170171
rimraf.sync(tempDir);

packages/pkg/bin/cli.mjs

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,2 @@
11
#!/usr/bin/env node
2-
3-
import { fileURLToPath } from 'url';
4-
import consola from 'consola';
5-
import { cac } from 'cac';
6-
import { readFileSync } from 'fs';
7-
import { join, dirname } from 'path';
8-
import pkgService, { getBuiltInPlugins } from '../lib/index.js';
9-
10-
const __dirname = dirname(fileURLToPath(import.meta.url));
11-
12-
const cli = cac('ice-pkg');
13-
14-
(async () => {
15-
cli
16-
.command('build', 'Bundle files', {
17-
allowUnknownOptions: false,
18-
})
19-
.option('--config <config>', 'specify custom config path')
20-
.option('--analyzer', "visualize size of output files(it's only valid in bundle mode)", {
21-
default: false,
22-
})
23-
.option('--rootDir <rootDir>', 'specify root directory', {
24-
default: process.cwd(),
25-
})
26-
.action(async (options) => {
27-
delete options['--'];
28-
const { rootDir, ...commandArgs } = options;
29-
30-
await pkgService.run({
31-
command: 'build',
32-
commandArgs,
33-
getBuiltInPlugins,
34-
rootDir: options.rootDir,
35-
});
36-
});
37-
38-
cli
39-
.command('start', 'Watch files', {
40-
allowUnknownOptions: false,
41-
})
42-
.option('--config <config>', 'specify custom config path')
43-
.option('--analyzer', "visualize size of output files(it's only valid in bundle mode)", {
44-
default: false,
45-
})
46-
.option('--rootDir <rootDir>', 'specify root directory', {
47-
default: process.cwd(),
48-
})
49-
.action(async (options) => {
50-
delete options['--'];
51-
const { rootDir, ...commandArgs } = options;
52-
53-
await pkgService.run({
54-
command: 'start',
55-
commandArgs,
56-
getBuiltInPlugins,
57-
rootDir: options.rootDir,
58-
});
59-
});
60-
61-
cli.help();
62-
63-
const pkgPath = join(__dirname, '../package.json');
64-
cli.version(JSON.parse(readFileSync(pkgPath, 'utf-8')).version);
65-
66-
cli.parse(process.argv, { run: true });
67-
})()
68-
.catch((err) => {
69-
consola.error(err);
70-
process.exit(1);
71-
});
2+
import '../lib/cli.js';

packages/pkg/package.json

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"license": "MIT",
2121
"engines": {
22-
"node": ">=16.14.0"
22+
"node": ">=18"
2323
},
2424
"repository": {
2525
"type": "git",
@@ -37,37 +37,39 @@
3737
"@babel/preset-react": "^7.18.6",
3838
"@babel/preset-typescript": "^7.18.6",
3939
"@rollup/plugin-alias": "^5.0.1",
40-
"@rollup/plugin-commonjs": "^25.0.0",
41-
"@rollup/plugin-image": "^3.0.1",
42-
"@rollup/plugin-json": "^4.1.0",
43-
"@rollup/plugin-node-resolve": "^15.0.2",
44-
"@rollup/plugin-replace": "^5.0.1",
45-
"@rollup/pluginutils": "^4.1.2",
46-
"@swc/core": "1.3.80",
47-
"acorn": "^8.7.0",
40+
"@rollup/plugin-commonjs": "^28.0.0",
41+
"@rollup/plugin-image": "^3.0.3",
42+
"@rollup/plugin-json": "^6.0.1",
43+
"@rollup/plugin-node-resolve": "^15.2.2",
44+
"@rollup/plugin-replace": "^6.0.0",
45+
"@rollup/pluginutils": "^5.0.5",
46+
"@swc/core": "1.7.40",
47+
"acorn": "^8.10.0",
4848
"autoprefixer": "^10.4.2",
4949
"build-scripts": "^2.0.0",
5050
"cac": "^6.7.12",
5151
"chokidar": "^3.5.3",
52+
"cli-spinners": "^2.9.2",
5253
"consola": "^2.15.3",
5354
"debug": "^4.3.3",
5455
"deepmerge": "^4.2.2",
5556
"es-module-lexer": "^1.3.1",
5657
"escape-string-regexp": "^5.0.0",
58+
"figures": "^6.1.0",
5759
"fs-extra": "^10.0.0",
5860
"globby": "^11.0.4",
5961
"gzip-size": "^7.0.0",
6062
"lodash.merge": "^4.6.2",
6163
"magic-string": "^0.25.7",
6264
"picocolors": "^1.0.0",
63-
"postcss": "^8.4.6",
65+
"postcss": "^8.4.31",
6466
"postcss-plugin-rpx2vw": "^1.0.0",
65-
"rollup": "^2.79.1",
66-
"rollup-plugin-styles": "^4.0.0",
67-
"rollup-plugin-visualizer": "^5.8.3",
68-
"semver": "^7.0.0",
67+
"rollup": "^4.0.0",
68+
"rollup-plugin-styler": "^1.8.0",
69+
"rollup-plugin-visualizer": "^5.12.0",
70+
"semver": "^7.5.2",
6971
"tsc-alias": "^1.8.2",
70-
"typescript": "^4.9.4"
72+
"typescript": "^4.9.5"
7173
},
7274
"devDependencies": {
7375
"@types/babel__core": "^7.1.20",

packages/pkg/src/cli.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { fileURLToPath } from 'node:url';
2+
import consola from 'consola';
3+
import { cac } from 'cac';
4+
import { readFileSync } from 'node:fs';
5+
import { join, dirname } from 'node:path';
6+
import { pkgService } from './service.js';
7+
import { getBuiltInPlugins } from './utils.js';
8+
9+
const __dirname = dirname(fileURLToPath(import.meta.url));
10+
11+
const cli = cac('ice-pkg');
12+
13+
(async () => {
14+
cli
15+
.command('build', 'Bundle files', {
16+
allowUnknownOptions: false,
17+
})
18+
.option('--config <config>', 'specify custom config path')
19+
.option('--analyzer', "visualize size of output files(it's only valid in bundle mode)", {
20+
default: false,
21+
})
22+
.option('--rootDir <rootDir>', 'specify root directory', {
23+
default: process.cwd(),
24+
})
25+
.action(async (options) => {
26+
delete options['--'];
27+
const { rootDir, ...commandArgs } = options;
28+
29+
await pkgService.run({
30+
command: 'build',
31+
commandArgs,
32+
getBuiltInPlugins,
33+
rootDir: options.rootDir,
34+
});
35+
});
36+
37+
cli
38+
.command('start', 'Watch files', {
39+
allowUnknownOptions: false,
40+
})
41+
.option('--config <config>', 'specify custom config path')
42+
.option('--analyzer', "visualize size of output files(it's only valid in bundle mode)", {
43+
default: false,
44+
})
45+
.option('--rootDir <rootDir>', 'specify root directory', {
46+
default: process.cwd(),
47+
})
48+
.action(async (options) => {
49+
delete options['--'];
50+
const { rootDir, ...commandArgs } = options;
51+
52+
await pkgService.run({
53+
command: 'start',
54+
commandArgs,
55+
getBuiltInPlugins,
56+
rootDir: options.rootDir,
57+
});
58+
});
59+
60+
cli.help();
61+
62+
const pkgPath = join(__dirname, '../package.json');
63+
cli.version(JSON.parse(readFileSync(pkgPath, 'utf-8')).version);
64+
65+
cli.parse(process.argv, { run: true });
66+
})()
67+
.catch((err) => {
68+
consola.error(err);
69+
process.exit(1);
70+
});

0 commit comments

Comments
 (0)