Skip to content

Commit 0ea3f24

Browse files
authored
fix: support modes which is removed in the previous version(1.5.23) (#654)
1 parent 88d0ed0 commit 0ea3f24

File tree

7 files changed

+105
-5
lines changed

7 files changed

+105
-5
lines changed

packages/pkg/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.5.24
4+
5+
### Patch Changes
6+
7+
- support modes which is removed in the previous version(1.5.23)
8+
39
## 1.5.23
410

511
### Patch Changes

packages/pkg/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/pkg",
3-
"version": "1.5.23",
3+
"version": "1.5.24",
44
"description": "A fast builder for React components, Node modules and web libraries.",
55
"type": "module",
66
"main": "./lib/index.js",

packages/pkg/src/config/userConfig.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {
1313
function getUserConfig() {
1414
const defaultBundleUserConfig: BundleUserConfig = {
1515
formats: ['esm', 'es2017'],
16-
modes: ['production'],
1716
outputDir: 'dist',
1817
minify: {
1918
js: (mode: string, command: string) => { return mode === 'production' && command === 'build'; },

packages/pkg/src/helpers/getBuildTasks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function getBuildTask(buildTask: BuildTask, context: Context): BuildTask {
2929
config.sourcemap = config.sourcemap ?? command === 'start';
3030

3131
const mode = command === 'build' ? 'production' : 'development';
32-
config.modes = [mode];
3332

3433
if (config.type === 'bundle') {
3534
const defaultBundleSwcConfig = getDefaultBundleSwcConfig(config, context, taskName);
@@ -39,8 +38,10 @@ function getBuildTask(buildTask: BuildTask, context: Context): BuildTask {
3938
defaultBundleSwcConfig,
4039
config.swcCompileOptions || {},
4140
);
41+
config.modes = config.modes ?? [mode];
4242
} else if (config.type === 'transform') {
4343
config.outputDir = getTransformDefaultOutputDir(rootDir, taskName);
44+
config.modes = [mode];
4445
const defaultTransformSwcConfig = getDefaultTransformSwcConfig(config, context, taskName, mode);
4546
config.swcCompileOptions = typeof config.modifySwcCompileOptions === 'function' ?
4647
config.modifySwcCompileOptions(defaultTransformSwcConfig) :

packages/pkg/tests/projects/__snapshots__/default.test.ts.snap

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,65 @@ exports[`Run config bundle-full > es2017 structure 1`] = `null`;
5252

5353
exports[`Run config bundle-full > esm structure 1`] = `null`;
5454

55+
exports[`Run config bundle-with-dev-mode > cjs structure 1`] = `null`;
56+
57+
exports[`Run config bundle-with-dev-mode > dist structure 1`] = `
58+
{
59+
"files": [
60+
{
61+
"name": "index.esm.es2017.development.js",
62+
},
63+
{
64+
"name": "index.esm.es5.development.js",
65+
},
66+
],
67+
"name": "dist",
68+
}
69+
`;
70+
71+
exports[`Run config bundle-with-dev-mode > es2017 structure 1`] = `null`;
72+
73+
exports[`Run config bundle-with-dev-mode > esm structure 1`] = `null`;
74+
75+
exports[`Run config bundle-with-empty-mode > cjs structure 1`] = `null`;
76+
77+
exports[`Run config bundle-with-empty-mode > dist structure 1`] = `
78+
{
79+
"files": [],
80+
"name": "dist",
81+
}
82+
`;
83+
84+
exports[`Run config bundle-with-empty-mode > es2017 structure 1`] = `null`;
85+
86+
exports[`Run config bundle-with-empty-mode > esm structure 1`] = `null`;
87+
88+
exports[`Run config bundle-with-full-modes > cjs structure 1`] = `null`;
89+
90+
exports[`Run config bundle-with-full-modes > dist structure 1`] = `
91+
{
92+
"files": [
93+
{
94+
"name": "index.esm.es2017.development.js",
95+
},
96+
{
97+
"name": "index.esm.es2017.production.js",
98+
},
99+
{
100+
"name": "index.esm.es5.development.js",
101+
},
102+
{
103+
"name": "index.esm.es5.production.js",
104+
},
105+
],
106+
"name": "dist",
107+
}
108+
`;
109+
110+
exports[`Run config bundle-with-full-modes > es2017 structure 1`] = `null`;
111+
112+
exports[`Run config bundle-with-full-modes > esm structure 1`] = `null`;
113+
55114
exports[`Run config default > cjs structure 1`] = `null`;
56115

57116
exports[`Run config default > dist structure 1`] = `null`;

packages/pkg/tests/projects/default.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,36 @@ runProjectTest('default', [
2424
}
2525
}
2626
},
27+
{
28+
name: 'bundle-with-full-modes',
29+
snapshot: 'structure',
30+
config: {
31+
transform: { formats: [] },
32+
bundle: {
33+
modes: ['development', 'production']
34+
}
35+
}
36+
},
37+
{
38+
name: 'bundle-with-dev-mode',
39+
snapshot: 'structure',
40+
config: {
41+
transform: { formats: [] },
42+
bundle: {
43+
modes: ['development']
44+
}
45+
}
46+
},
47+
{
48+
name: 'bundle-with-empty-mode',
49+
snapshot: 'structure',
50+
config: {
51+
transform: { formats: [] },
52+
bundle: {
53+
modes: []
54+
}
55+
}
56+
},
2757
{
2858
name: 'sourcemap-enable',
2959
snapshot: 'structure',

packages/pkg/tests/projects/helper.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export interface ProjectTestUserConfig {
1515
config?: string | UserConfig
1616
mode?: 'build' | 'start'
1717
snapshot?: 'full' | 'structure'
18+
skip?: boolean
19+
only?: boolean
1820
}
1921

2022
export interface ProjectTestConfig extends Required<ProjectTestUserConfig> {
@@ -40,7 +42,9 @@ export function runProjectTest(name: string, userConfigs: ProjectTestConfigs) {
4042
name: config.name,
4143
config: config.config,
4244
mode: config?.mode ?? 'build',
43-
snapshot: config?.snapshot ?? 'full'
45+
snapshot: config?.snapshot ?? 'full',
46+
skip: config.skip ?? false,
47+
only: config.only ?? false,
4448
})
4549
}
4650

@@ -93,7 +97,8 @@ export function runProjectTest(name: string, userConfigs: ProjectTestConfigs) {
9397
})
9498

9599
for (const config of configs) {
96-
it(`Run config ${config.name}`, async () => {
100+
const test = config.only ? it.only : config.skip ? it.skip : it;
101+
test(`Run config ${config.name}`, async () => {
97102
await runBuild(config)
98103
await runSnapshot(config)
99104
}, {

0 commit comments

Comments
 (0)