@modern-js/builder 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/plugins/cache.d.ts +1 -1
- package/dist/plugins/cache.js +3 -3
- package/dist/plugins/cleanOutput.d.ts +1 -1
- package/dist/plugins/cleanOutput.js +3 -3
- package/dist/plugins/devtool.d.ts +1 -1
- package/dist/plugins/devtool.js +3 -3
- package/dist/plugins/entry.d.ts +1 -1
- package/dist/plugins/entry.js +3 -3
- package/dist/plugins/fileSize.d.ts +1 -1
- package/dist/plugins/fileSize.js +3 -3
- package/dist/plugins/index.js +9 -9
- package/dist/plugins/startUrl.d.ts +2 -1
- package/dist/plugins/startUrl.js +10 -8
- package/dist/plugins/target.d.ts +1 -1
- package/dist/plugins/target.js +3 -3
- package/dist/plugins/toml.d.ts +1 -1
- package/dist/plugins/toml.js +3 -3
- package/dist/plugins/yaml.d.ts +1 -1
- package/dist/plugins/yaml.js +3 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @modern-js/builder
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d82b621: feat(builder): support port placeholder in dev.startUrl config
|
|
8
|
+
|
|
9
|
+
feat(builder): 支持在 dev.startUrl 配置项中使用端口号占位符
|
|
10
|
+
|
|
11
|
+
- 16bdc0a: chore: adjust builder plugin name
|
|
12
|
+
|
|
13
|
+
chore: 调整 builder 插件命名格式
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [f2f8a83]
|
|
16
|
+
- Updated dependencies [49eff0c]
|
|
17
|
+
- @modern-js/builder-shared@2.2.0
|
|
18
|
+
- @modern-js/utils@2.2.0
|
|
19
|
+
|
|
3
20
|
## 2.1.0
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/plugins/cache.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const builderPluginCache: () => DefaultBuilderPlugin;
|
package/dist/plugins/cache.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.builderPluginCache = void 0;
|
|
27
27
|
const path_1 = require("path");
|
|
28
28
|
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
29
29
|
async function validateCache(cacheDirectory, buildDependencies) {
|
|
@@ -51,7 +51,7 @@ function getCacheDirectory({ cacheDirectory }, context) {
|
|
|
51
51
|
}
|
|
52
52
|
return (0, path_1.join)(context.cachePath, context.bundlerType);
|
|
53
53
|
}
|
|
54
|
-
const
|
|
54
|
+
const builderPluginCache = () => ({
|
|
55
55
|
name: 'builder-plugin-cache',
|
|
56
56
|
setup(api) {
|
|
57
57
|
api.modifyBundlerChain(async (chain, { target, env }) => {
|
|
@@ -93,4 +93,4 @@ const PluginCache = () => ({
|
|
|
93
93
|
});
|
|
94
94
|
},
|
|
95
95
|
});
|
|
96
|
-
exports.
|
|
96
|
+
exports.builderPluginCache = builderPluginCache;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const builderPluginCleanOutput: () => DefaultBuilderPlugin;
|
|
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
const
|
|
26
|
+
exports.builderPluginCleanOutput = void 0;
|
|
27
|
+
const builderPluginCleanOutput = () => ({
|
|
28
28
|
name: 'builder-plugin-clean-output',
|
|
29
29
|
setup(api) {
|
|
30
30
|
const clean = async () => {
|
|
@@ -39,4 +39,4 @@ const PluginCleanOutput = () => ({
|
|
|
39
39
|
api.onBeforeStartDevServer(clean);
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
|
-
exports.
|
|
42
|
+
exports.builderPluginCleanOutput = builderPluginCleanOutput;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const builderPluginDevtool: () => DefaultBuilderPlugin;
|
package/dist/plugins/devtool.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.builderPluginDevtool = void 0;
|
|
4
4
|
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
5
|
-
const
|
|
5
|
+
const builderPluginDevtool = () => ({
|
|
6
6
|
name: 'builder-plugin-devtool',
|
|
7
7
|
setup(api) {
|
|
8
8
|
api.modifyBundlerChain((chain, { isProd }) => {
|
|
@@ -20,4 +20,4 @@ const PluginDevtool = () => ({
|
|
|
20
20
|
});
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
|
-
exports.
|
|
23
|
+
exports.builderPluginDevtool = builderPluginDevtool;
|
package/dist/plugins/entry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const builderPluginEntry: () => DefaultBuilderPlugin;
|
package/dist/plugins/entry.js
CHANGED
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.builderPluginEntry = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("@modern-js/utils/lodash"));
|
|
8
|
-
const
|
|
8
|
+
const builderPluginEntry = () => ({
|
|
9
9
|
name: 'builder-plugin-entry',
|
|
10
10
|
setup(api) {
|
|
11
11
|
api.modifyBundlerChain(async (chain) => {
|
|
@@ -19,4 +19,4 @@ const PluginEntry = () => ({
|
|
|
19
19
|
});
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
|
-
exports.
|
|
22
|
+
exports.builderPluginEntry = builderPluginEntry;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
2
|
/** Filter source map files */
|
|
3
3
|
export declare const filterAsset: (asset: string) => boolean;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const builderPluginFileSize: () => DefaultBuilderPlugin;
|
package/dist/plugins/fileSize.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.builderPluginFileSize = exports.filterAsset = void 0;
|
|
30
30
|
/**
|
|
31
31
|
* modified from https://github.com/facebook/create-react-app
|
|
32
32
|
* license at https://github.com/facebook/create-react-app/blob/master/LICENSE
|
|
@@ -116,7 +116,7 @@ async function printFileSizes(stats, distPath) {
|
|
|
116
116
|
});
|
|
117
117
|
builder_shared_1.logger.log('');
|
|
118
118
|
}
|
|
119
|
-
const
|
|
119
|
+
const builderPluginFileSize = () => ({
|
|
120
120
|
name: 'builder-plugin-file-size',
|
|
121
121
|
setup(api) {
|
|
122
122
|
api.onAfterBuild(async ({ stats }) => {
|
|
@@ -127,4 +127,4 @@ const PluginFileSize = () => ({
|
|
|
127
127
|
});
|
|
128
128
|
},
|
|
129
129
|
});
|
|
130
|
-
exports.
|
|
130
|
+
exports.builderPluginFileSize = builderPluginFileSize;
|
package/dist/plugins/index.js
CHANGED
|
@@ -25,13 +25,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.plugins = void 0;
|
|
27
27
|
exports.plugins = {
|
|
28
|
-
cleanOutput: () => Promise.resolve().then(() => __importStar(require('./cleanOutput'))).then(m => m.
|
|
29
|
-
startUrl: () => Promise.resolve().then(() => __importStar(require('./startUrl'))).then(m => m.
|
|
30
|
-
fileSize: () => Promise.resolve().then(() => __importStar(require('./fileSize'))).then(m => m.
|
|
31
|
-
devtool: () => Promise.resolve().then(() => __importStar(require('./devtool'))).then(m => m.
|
|
32
|
-
target: () => Promise.resolve().then(() => __importStar(require('./target'))).then(m => m.
|
|
33
|
-
entry: () => Promise.resolve().then(() => __importStar(require('./entry'))).then(m => m.
|
|
34
|
-
cache: () => Promise.resolve().then(() => __importStar(require('./cache'))).then(m => m.
|
|
35
|
-
yaml: () => Promise.resolve().then(() => __importStar(require('./yaml'))).then(m => m.
|
|
36
|
-
toml: () => Promise.resolve().then(() => __importStar(require('./toml'))).then(m => m.
|
|
28
|
+
cleanOutput: () => Promise.resolve().then(() => __importStar(require('./cleanOutput'))).then(m => m.builderPluginCleanOutput()),
|
|
29
|
+
startUrl: () => Promise.resolve().then(() => __importStar(require('./startUrl'))).then(m => m.builderPluginStartUrl()),
|
|
30
|
+
fileSize: () => Promise.resolve().then(() => __importStar(require('./fileSize'))).then(m => m.builderPluginFileSize()),
|
|
31
|
+
devtool: () => Promise.resolve().then(() => __importStar(require('./devtool'))).then(m => m.builderPluginDevtool()),
|
|
32
|
+
target: () => Promise.resolve().then(() => __importStar(require('./target'))).then(m => m.builderPluginTarget()),
|
|
33
|
+
entry: () => Promise.resolve().then(() => __importStar(require('./entry'))).then(m => m.builderPluginEntry()),
|
|
34
|
+
cache: () => Promise.resolve().then(() => __importStar(require('./cache'))).then(m => m.builderPluginCache()),
|
|
35
|
+
yaml: () => Promise.resolve().then(() => __importStar(require('./yaml'))).then(m => m.builderPluginYaml()),
|
|
36
|
+
toml: () => Promise.resolve().then(() => __importStar(require('./toml'))).then(m => m.builderPluginToml()),
|
|
37
37
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const replacePlaceholder: (url: string, port: number) => string;
|
|
3
|
+
export declare function builderPluginStartUrl(): DefaultBuilderPlugin;
|
package/dist/plugins/startUrl.js
CHANGED
|
@@ -26,9 +26,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.builderPluginStartUrl = exports.replacePlaceholder = void 0;
|
|
30
30
|
const lodash_1 = __importDefault(require("@modern-js/utils/lodash"));
|
|
31
|
-
|
|
31
|
+
const replacePlaceholder = (url, port) => url.replace(/<port>/g, String(port));
|
|
32
|
+
exports.replacePlaceholder = replacePlaceholder;
|
|
33
|
+
function builderPluginStartUrl() {
|
|
32
34
|
return {
|
|
33
35
|
name: 'builder-plugin-start-url',
|
|
34
36
|
async setup(api) {
|
|
@@ -41,24 +43,24 @@ function PluginStartUrl() {
|
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
43
45
|
const config = api.getNormalizedConfig();
|
|
44
|
-
const { startUrl } = config.dev;
|
|
46
|
+
const { https, startUrl } = config.dev;
|
|
45
47
|
if (!startUrl) {
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
|
-
const { default: open } = await Promise.resolve().then(() => __importStar(require('@modern-js/builder-shared/open')));
|
|
49
50
|
const urls = [];
|
|
50
51
|
if (startUrl === true) {
|
|
51
|
-
const protocol =
|
|
52
|
+
const protocol = https ? 'https' : 'http';
|
|
52
53
|
urls.push(`${protocol}://localhost:${port}`);
|
|
53
54
|
}
|
|
54
55
|
else {
|
|
55
|
-
urls.push(...lodash_1.default.castArray(startUrl));
|
|
56
|
+
urls.push(...lodash_1.default.castArray(startUrl).map(item => (0, exports.replacePlaceholder)(item, port)));
|
|
56
57
|
}
|
|
58
|
+
const { openBrowser } = await Promise.resolve().then(() => __importStar(require('@modern-js/builder-shared')));
|
|
57
59
|
for (const url of urls) {
|
|
58
|
-
await
|
|
60
|
+
await openBrowser(url);
|
|
59
61
|
}
|
|
60
62
|
});
|
|
61
63
|
},
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
|
-
exports.
|
|
66
|
+
exports.builderPluginStartUrl = builderPluginStartUrl;
|
package/dist/plugins/target.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const builderPluginTarget: () => DefaultBuilderPlugin;
|
package/dist/plugins/target.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.builderPluginTarget = void 0;
|
|
4
4
|
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
5
|
-
const
|
|
5
|
+
const builderPluginTarget = () => ({
|
|
6
6
|
name: 'builder-plugin-target',
|
|
7
7
|
setup(api) {
|
|
8
8
|
api.modifyBundlerChain(async (chain, { target }) => {
|
|
@@ -24,4 +24,4 @@ const PluginTarget = () => ({
|
|
|
24
24
|
});
|
|
25
25
|
},
|
|
26
26
|
});
|
|
27
|
-
exports.
|
|
27
|
+
exports.builderPluginTarget = builderPluginTarget;
|
package/dist/plugins/toml.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const builderPluginToml: () => DefaultBuilderPlugin;
|
package/dist/plugins/toml.js
CHANGED
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.builderPluginToml = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const
|
|
8
|
+
const builderPluginToml = () => ({
|
|
9
9
|
name: 'builder-plugin-toml',
|
|
10
10
|
setup(api) {
|
|
11
11
|
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
@@ -18,4 +18,4 @@ const PluginToml = () => ({
|
|
|
18
18
|
});
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
|
-
exports.
|
|
21
|
+
exports.builderPluginToml = builderPluginToml;
|
package/dist/plugins/yaml.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const builderPluginYaml: () => DefaultBuilderPlugin;
|
package/dist/plugins/yaml.js
CHANGED
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.builderPluginYaml = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const
|
|
8
|
+
const builderPluginYaml = () => ({
|
|
9
9
|
name: 'builder-plugin-yaml',
|
|
10
10
|
setup(api) {
|
|
11
11
|
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
@@ -18,4 +18,4 @@ const PluginYaml = () => ({
|
|
|
18
18
|
});
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
|
-
exports.
|
|
21
|
+
exports.builderPluginYaml = builderPluginYaml;
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14.0.0"
|
|
16
16
|
},
|
|
17
|
-
"version": "2.
|
|
17
|
+
"version": "2.2.0",
|
|
18
18
|
"jsnext:source": "./src/index.ts",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"main": "./dist/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@modern-js/builder-shared": "2.
|
|
31
|
-
"@modern-js/utils": "2.
|
|
30
|
+
"@modern-js/builder-shared": "2.2.0",
|
|
31
|
+
"@modern-js/utils": "2.2.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/core": "7.18.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/babel__preset-env": "^7.9.2",
|
|
37
37
|
"@types/node": "^14",
|
|
38
38
|
"typescript": "^4",
|
|
39
|
-
"@scripts/vitest-config": "2.
|
|
39
|
+
"@scripts/vitest-config": "2.2.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"registry": "https://registry.npmjs.org/",
|