Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade rollup to v4 #664

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-camels-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/pkg': major
---

feat: upgrade rollup to v4 and other packages
32 changes: 15 additions & 17 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,30 @@ coverage/
node_modules
extensions/*/out
.vscode-test
packages/**/lib/
packages/**/es/
packages/**/esnext/
packages/**/esm/
packages/**/es2017/
packages/**/cjs/
packages/**/build/
packages/*/lib/
packages/*/es/
packages/*/esnext/
packages/*/esm/
packages/*/es2017/
packages/*/cjs/
packages/*/build/
packages/build-plugin-component/*/template
app/main_dist/
app/build/
tmp
.tmp
__mocks__
__tests__

# 忽略文件
**/*-min.js
**/*.min.js

lib
node_modules
__tests__
examples/**/esm
examples/**/es
examples/**/es2017
examples/**/cjs
examples/**/lib
examples/**/dist
examples/**/build
examples/*/esm
examples/*/es
examples/*/es2017
examples/*/cjs
examples/*/lib
examples/*/dist
examples/*/build
examples/*/typings
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ examples/**/.vscode
examples/**/.DS_Store
examples/**/.docusaurus
examples/**/build
examples/**/typings
19 changes: 9 additions & 10 deletions examples/react-component/build.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { defineConfig } from '@ice/pkg';
// https://pkg.ice.work/reference/config-list
export default defineConfig({
plugins: [
[
'@ice/pkg-plugin-docusaurus',
{
remarkPlugins: [
"require('@ice/remark-react-docgen-docusaurus')",
// "[require('remark-react-docgen'), {}]",
],
},
],
// [
XGHeaven marked this conversation as resolved.
Show resolved Hide resolved
// '@ice/pkg-plugin-docusaurus',
// {
// remarkPlugins: [
// "require('@ice/remark-react-docgen-docusaurus')",
// // "[require('remark-react-docgen'), {}]",
// ],
// },
// ],
['@ice/pkg-plugin-jsx-plus'],
],
transform: {
Expand All @@ -21,7 +21,6 @@ export default defineConfig({
sourceMaps: false,
bundle: {
formats: ['esm', 'es2017'],
development: true,
},
alias: {
'@': './src',
Expand Down
5 changes: 3 additions & 2 deletions examples/react-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
},
"dependencies": {
"@ice/jsx-runtime": "^0.2.0",
"@swc/helpers": "^0.5.1",
"babel-runtime-jsx-plus": "^0.1.5"
"@swc/helpers": "^0.5.13",
"babel-runtime-jsx-plus": "^0.1.5",
"core-js": "^3.38.1"
},
"devDependencies": {
"@ice/pkg": "workspace:*",
Expand Down
7 changes: 4 additions & 3 deletions packages/ice-npm-utils/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test('getUnpkgHost custom host', () => {
});

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

expect(getUnpkgHost('koa')).toBe(defaultRegistry);
Expand Down Expand Up @@ -123,7 +124,7 @@ test('getNpmTarball', () => {
console.log('getNpmTarball ice-npm-utils', tarball);
expect(
tbRegisties
.some(registry => tarball === `${registry}/ice-npm-utils/-/ice-npm-utils-1.0.0.tgz`)
.some((registry) => tarball === `${registry}/ice-npm-utils/-/ice-npm-utils-1.0.0.tgz`),
).toBeTruthy();
});
});
Expand All @@ -139,7 +140,7 @@ test('getNpmTarball should get latest version', () => {
console.log('getNpmTarball http', tarball);
expect(
tbRegisties
.some(registry => tarball === `${registry}/http/-/http-0.0.1-security.tgz`)
.some((registry) => tarball === `${registry}/http/-/http-0.0.1-security.tgz`),
).toBeTruthy();
});
});
Expand All @@ -164,7 +165,7 @@ test('getAndExtractTarballWithDir', () => {
const tempDir = path.resolve(tmpdir(), 'babel_helper_function_name_tarball');
return getAndExtractTarball(
tempDir,
`${defaultRegistry}/@babel/helper-function-name/download/@babel/helper-function-name-7.1.0.tgz`
`${defaultRegistry}/@babel/helper-function-name/download/@babel/helper-function-name-7.1.0.tgz`,
)
.then((files) => {
rimraf.sync(tempDir);
Expand Down
71 changes: 1 addition & 70 deletions packages/pkg/bin/cli.mjs
Original file line number Diff line number Diff line change
@@ -1,71 +1,2 @@
#!/usr/bin/env node

import { fileURLToPath } from 'url';
import consola from 'consola';
import { cac } from 'cac';
import { readFileSync } from 'fs';
import { join, dirname } from 'path';
import pkgService, { getBuiltInPlugins } from '../lib/index.js';

const __dirname = dirname(fileURLToPath(import.meta.url));

const cli = cac('ice-pkg');

(async () => {
cli
.command('build', 'Bundle files', {
allowUnknownOptions: false,
})
.option('--config <config>', 'specify custom config path')
.option('--analyzer', "visualize size of output files(it's only valid in bundle mode)", {
default: false,
})
.option('--rootDir <rootDir>', 'specify root directory', {
default: process.cwd(),
})
.action(async (options) => {
delete options['--'];
const { rootDir, ...commandArgs } = options;

await pkgService.run({
command: 'build',
commandArgs,
getBuiltInPlugins,
rootDir: options.rootDir,
});
});

cli
.command('start', 'Watch files', {
allowUnknownOptions: false,
})
.option('--config <config>', 'specify custom config path')
.option('--analyzer', "visualize size of output files(it's only valid in bundle mode)", {
default: false,
})
.option('--rootDir <rootDir>', 'specify root directory', {
default: process.cwd(),
})
.action(async (options) => {
delete options['--'];
const { rootDir, ...commandArgs } = options;

await pkgService.run({
command: 'start',
commandArgs,
getBuiltInPlugins,
rootDir: options.rootDir,
});
});

cli.help();

const pkgPath = join(__dirname, '../package.json');
cli.version(JSON.parse(readFileSync(pkgPath, 'utf-8')).version);

cli.parse(process.argv, { run: true });
})()
.catch((err) => {
consola.error(err);
process.exit(1);
});
import '../lib/cli.js';
32 changes: 17 additions & 15 deletions packages/pkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"license": "MIT",
"engines": {
"node": ">=16.14.0"
"node": ">=18"
},
"repository": {
"type": "git",
Expand All @@ -37,37 +37,39 @@
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@rollup/plugin-alias": "^5.0.1",
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-image": "^3.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.1",
"@rollup/pluginutils": "^4.1.2",
"@swc/core": "1.3.80",
"acorn": "^8.7.0",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-image": "^3.0.3",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-node-resolve": "^15.2.2",
"@rollup/plugin-replace": "^6.0.0",
"@rollup/pluginutils": "^5.0.5",
"@swc/core": "1.7.40",
"acorn": "^8.10.0",
"autoprefixer": "^10.4.2",
"build-scripts": "^2.0.0",
"cac": "^6.7.12",
"chokidar": "^3.5.3",
"cli-spinners": "^2.9.2",
"consola": "^2.15.3",
"debug": "^4.3.3",
"deepmerge": "^4.2.2",
"es-module-lexer": "^1.3.1",
"escape-string-regexp": "^5.0.0",
"figures": "^6.1.0",
"fs-extra": "^10.0.0",
"globby": "^11.0.4",
"gzip-size": "^7.0.0",
"lodash.merge": "^4.6.2",
"magic-string": "^0.25.7",
"picocolors": "^1.0.0",
"postcss": "^8.4.6",
"postcss": "^8.4.31",
"postcss-plugin-rpx2vw": "^1.0.0",
"rollup": "^2.79.1",
"rollup-plugin-styles": "^4.0.0",
"rollup-plugin-visualizer": "^5.8.3",
"semver": "^7.0.0",
"rollup": "^4.0.0",
"rollup-plugin-styler": "^1.8.0",
"rollup-plugin-visualizer": "^5.12.0",
"semver": "^7.5.2",
"tsc-alias": "^1.8.2",
"typescript": "^4.9.4"
"typescript": "^4.9.5"
},
"devDependencies": {
"@types/babel__core": "^7.1.20",
Expand Down
70 changes: 70 additions & 0 deletions packages/pkg/src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { fileURLToPath } from 'node:url';
import consola from 'consola';
import { cac } from 'cac';
import { readFileSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { pkgService } from './service.js';
import { getBuiltInPlugins } from './utils.js';

const __dirname = dirname(fileURLToPath(import.meta.url));

const cli = cac('ice-pkg');

(async () => {
cli
.command('build', 'Bundle files', {
allowUnknownOptions: false,
})
.option('--config <config>', 'specify custom config path')
.option('--analyzer', "visualize size of output files(it's only valid in bundle mode)", {
default: false,
})
.option('--rootDir <rootDir>', 'specify root directory', {
default: process.cwd(),
})
.action(async (options) => {
delete options['--'];
const { rootDir, ...commandArgs } = options;

await pkgService.run({
command: 'build',
commandArgs,
getBuiltInPlugins,
rootDir: options.rootDir,
});
});

cli
.command('start', 'Watch files', {
allowUnknownOptions: false,
})
.option('--config <config>', 'specify custom config path')
.option('--analyzer', "visualize size of output files(it's only valid in bundle mode)", {
default: false,
})
.option('--rootDir <rootDir>', 'specify root directory', {
default: process.cwd(),
})
.action(async (options) => {
delete options['--'];
const { rootDir, ...commandArgs } = options;

await pkgService.run({
command: 'start',
commandArgs,
getBuiltInPlugins,
rootDir: options.rootDir,
});
});

cli.help();

const pkgPath = join(__dirname, '../package.json');
cli.version(JSON.parse(readFileSync(pkgPath, 'utf-8')).version);

cli.parse(process.argv, { run: true });
})()
.catch((err) => {
consola.error(err);
process.exit(1);
});
Loading
Loading