@modern-js/builder 2.0.0-beta.2 → 2.0.0-beta.3
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/dist/createBuilder.js +2 -0
- package/dist/plugins/cleanOutput.d.ts +2 -0
- package/dist/plugins/cleanOutput.js +42 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +30 -0
- package/dist/plugins/startUrl.d.ts +2 -0
- package/dist/plugins/startUrl.js +64 -0
- package/package.json +4 -3
package/dist/createBuilder.js
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createBuilder = void 0;
|
|
4
4
|
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
5
|
+
const plugins_1 = require("./plugins");
|
|
5
6
|
async function createBuilder(provider, options) {
|
|
6
7
|
const builderOptions = (0, builder_shared_1.applyDefaultBuilderOptions)(options);
|
|
7
8
|
const pluginStore = (0, builder_shared_1.createPluginStore)();
|
|
8
9
|
const { build, publicContext, inspectConfig, createCompiler, startDevServer, applyDefaultPlugins, } = await provider({
|
|
9
10
|
pluginStore,
|
|
10
11
|
builderOptions,
|
|
12
|
+
plugins: plugins_1.plugins,
|
|
11
13
|
});
|
|
12
14
|
(0, builder_shared_1.debug)('add default plugins');
|
|
13
15
|
await applyDefaultPlugins(pluginStore);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.PluginCleanOutput = void 0;
|
|
27
|
+
const PluginCleanOutput = () => ({
|
|
28
|
+
name: 'builder-plugin-clean-output',
|
|
29
|
+
setup(api) {
|
|
30
|
+
const clean = async () => {
|
|
31
|
+
const config = api.getNormalizedConfig();
|
|
32
|
+
if (config.output.cleanDistPath) {
|
|
33
|
+
const { emptyDir } = await Promise.resolve().then(() => __importStar(require('@modern-js/utils')));
|
|
34
|
+
const { distPath } = api.context;
|
|
35
|
+
await emptyDir(distPath);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
api.onBeforeBuild(clean);
|
|
39
|
+
api.onBeforeStartDevServer(clean);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
exports.PluginCleanOutput = PluginCleanOutput;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.plugins = void 0;
|
|
27
|
+
exports.plugins = {
|
|
28
|
+
cleanOutput: () => Promise.resolve().then(() => __importStar(require('./cleanOutput'))).then(m => m.PluginCleanOutput()),
|
|
29
|
+
startUrl: () => Promise.resolve().then(() => __importStar(require('./startUrl'))).then(m => m.PluginStartUrl()),
|
|
30
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.PluginStartUrl = void 0;
|
|
30
|
+
const lodash_1 = __importDefault(require("@modern-js/utils/lodash"));
|
|
31
|
+
function PluginStartUrl() {
|
|
32
|
+
return {
|
|
33
|
+
name: 'builder-plugin-start-url',
|
|
34
|
+
async setup(api) {
|
|
35
|
+
let port;
|
|
36
|
+
api.onAfterStartDevServer(async (params) => {
|
|
37
|
+
({ port } = params);
|
|
38
|
+
});
|
|
39
|
+
api.onDevCompileDone(async ({ isFirstCompile }) => {
|
|
40
|
+
if (!isFirstCompile || !port) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const config = api.getNormalizedConfig();
|
|
44
|
+
const { startUrl } = config.dev;
|
|
45
|
+
if (!startUrl) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const { default: open } = await Promise.resolve().then(() => __importStar(require('@modern-js/builder-shared/open')));
|
|
49
|
+
const urls = [];
|
|
50
|
+
if (startUrl === true) {
|
|
51
|
+
const protocol = config.dev.https ? 'https' : 'http';
|
|
52
|
+
urls.push(`${protocol}://localhost:${port}`);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
urls.push(...lodash_1.default.castArray(startUrl));
|
|
56
|
+
}
|
|
57
|
+
for (const url of urls) {
|
|
58
|
+
await open(url);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
exports.PluginStartUrl = PluginStartUrl;
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14.0.0"
|
|
16
16
|
},
|
|
17
|
-
"version": "2.0.0-beta.
|
|
17
|
+
"version": "2.0.0-beta.3",
|
|
18
18
|
"jsnext:source": "./src/index.ts",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"main": "./dist/index.js",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@modern-js/builder-shared": "2.0.0-beta.
|
|
30
|
+
"@modern-js/builder-shared": "2.0.0-beta.3",
|
|
31
|
+
"@modern-js/utils": "2.0.0-beta.3"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@babel/core": "7.18.0",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"@types/babel__preset-env": "^7.9.2",
|
|
36
37
|
"@types/node": "^14",
|
|
37
38
|
"typescript": "^4",
|
|
38
|
-
"@scripts/vitest-config": "2.0.0-beta.
|
|
39
|
+
"@scripts/vitest-config": "2.0.0-beta.3"
|
|
39
40
|
},
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"registry": "https://registry.npmjs.org/",
|