@gravity-ui/app-builder 0.0.1
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 +14 -0
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +46 -0
- package/dist/commands/build/build-lib.d.ts +2 -0
- package/dist/commands/build/build-lib.js +39 -0
- package/dist/commands/build/build-service/client.d.ts +2 -0
- package/dist/commands/build/build-service/client.js +8 -0
- package/dist/commands/build/build-service/index.d.ts +2 -0
- package/dist/commands/build/build-service/index.js +46 -0
- package/dist/commands/build/build-service/server.d.ts +2 -0
- package/dist/commands/build/build-service/server.js +44 -0
- package/dist/commands/build/index.d.ts +2 -0
- package/dist/commands/build/index.js +33 -0
- package/dist/commands/dev/client.d.ts +3 -0
- package/dist/commands/dev/client.js +98 -0
- package/dist/commands/dev/index.d.ts +2 -0
- package/dist/commands/dev/index.js +101 -0
- package/dist/commands/dev/server.d.ts +3 -0
- package/dist/commands/dev/server.js +38 -0
- package/dist/common/babel/index.d.ts +15 -0
- package/dist/common/babel/index.js +17 -0
- package/dist/common/babel/ui-preset.d.ts +1 -0
- package/dist/common/babel/ui-preset.js +71 -0
- package/dist/common/child-process/controllable-script.d.ts +19 -0
- package/dist/common/child-process/controllable-script.js +125 -0
- package/dist/common/child-process/utils.d.ts +1 -0
- package/dist/common/child-process/utils.js +68 -0
- package/dist/common/command.d.ts +4 -0
- package/dist/common/command.js +2 -0
- package/dist/common/config.d.ts +5 -0
- package/dist/common/config.js +155 -0
- package/dist/common/env.d.ts +1 -0
- package/dist/common/env.js +5 -0
- package/dist/common/library/index.d.ts +2 -0
- package/dist/common/library/index.js +302 -0
- package/dist/common/links/link.d.ts +1 -0
- package/dist/common/links/link.js +109 -0
- package/dist/common/links/unlink.d.ts +3 -0
- package/dist/common/links/unlink.js +72 -0
- package/dist/common/logger/colors.d.ts +12 -0
- package/dist/common/logger/colors.js +8 -0
- package/dist/common/logger/index.d.ts +47 -0
- package/dist/common/logger/index.js +120 -0
- package/dist/common/logger/pretty-time.d.ts +2 -0
- package/dist/common/logger/pretty-time.js +51 -0
- package/dist/common/models/index.d.ts +184 -0
- package/dist/common/models/index.js +11 -0
- package/dist/common/package.d.ts +19 -0
- package/dist/common/package.js +42 -0
- package/dist/common/paths.d.ts +20 -0
- package/dist/common/paths.js +28 -0
- package/dist/common/s3-upload/compress.d.ts +2 -0
- package/dist/common/s3-upload/compress.js +23 -0
- package/dist/common/s3-upload/index.d.ts +3 -0
- package/dist/common/s3-upload/index.js +7 -0
- package/dist/common/s3-upload/s3-client.d.ts +20 -0
- package/dist/common/s3-upload/s3-client.js +111 -0
- package/dist/common/s3-upload/upload.d.ts +14 -0
- package/dist/common/s3-upload/upload.js +117 -0
- package/dist/common/s3-upload/webpack-plugin.d.ts +18 -0
- package/dist/common/s3-upload/webpack-plugin.js +53 -0
- package/dist/common/tempData.d.ts +13 -0
- package/dist/common/tempData.js +43 -0
- package/dist/common/typescript/compile.d.ts +5 -0
- package/dist/common/typescript/compile.js +72 -0
- package/dist/common/typescript/diagnostic.d.ts +2 -0
- package/dist/common/typescript/diagnostic.js +46 -0
- package/dist/common/typescript/transformers.d.ts +2 -0
- package/dist/common/typescript/transformers.js +114 -0
- package/dist/common/typescript/utils.d.ts +10 -0
- package/dist/common/typescript/utils.js +53 -0
- package/dist/common/typescript/watch.d.ts +7 -0
- package/dist/common/typescript/watch.js +60 -0
- package/dist/common/utils.d.ts +2 -0
- package/dist/common/utils.js +19 -0
- package/dist/common/webpack/compile.d.ts +2 -0
- package/dist/common/webpack/compile.js +31 -0
- package/dist/common/webpack/config.d.ts +23 -0
- package/dist/common/webpack/config.js +662 -0
- package/dist/common/webpack/progress-plugin.d.ts +11 -0
- package/dist/common/webpack/progress-plugin.js +64 -0
- package/dist/common/webpack/public-path.d.ts +1 -0
- package/dist/common/webpack/public-path.js +2 -0
- package/dist/common/webpack/storybook.d.ts +13 -0
- package/dist/common/webpack/storybook.js +86 -0
- package/dist/common/webpack/utils.d.ts +7 -0
- package/dist/common/webpack/utils.js +71 -0
- package/dist/create-cli.d.ts +54 -0
- package/dist/create-cli.js +221 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/package.json +154 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.0.1 (2022-12-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add client and server keys to confg ([79d968f](https://github.com/gravity-ui/app-builder/commit/79d968f275b972d7376c90dba1b6cacfe05e4310))
|
|
9
|
+
* upload to s3 ([e6e5fbc](https://github.com/gravity-ui/app-builder/commit/e6e5fbc89e402ad595db8b1aee8c17f7adb41e2c))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### chore
|
|
13
|
+
|
|
14
|
+
* release 0.0.1 ([3d58428](https://github.com/gravity-ui/app-builder/commit/3d58428c4df316f098c23dbc7264219cf2e08bf7))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 YANDEX LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @gravity-ui/app-builder · [](https://www.npmjs.com/package/@gravity-ui/app-builder) [](https://github.com/gravity-ui/app-builder/actions/workflows/ci.yml?query=branch:main)
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install --save-dev @gravity-ui/app-builder
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const semver_1 = __importDefault(require("semver"));
|
|
8
|
+
const util_1 = __importDefault(require("util"));
|
|
9
|
+
const common_tags_1 = require("common-tags");
|
|
10
|
+
require("./common/env");
|
|
11
|
+
const logger_1 = __importDefault(require("./common/logger"));
|
|
12
|
+
const create_cli_1 = require("./create-cli");
|
|
13
|
+
const MIN_NODE_VERSION = '14.15.0';
|
|
14
|
+
const { version } = process;
|
|
15
|
+
if (!semver_1.default.satisfies(version, `>=${MIN_NODE_VERSION}`, {
|
|
16
|
+
includePrerelease: true,
|
|
17
|
+
})) {
|
|
18
|
+
logger_1.default.panic((0, common_tags_1.stripIndent)(`
|
|
19
|
+
App-builder requires Node.js ${MIN_NODE_VERSION} or higher (you have ${version}).
|
|
20
|
+
Upgrade Node to the latest stable release.
|
|
21
|
+
`));
|
|
22
|
+
}
|
|
23
|
+
if (semver_1.default.prerelease(version)) {
|
|
24
|
+
logger_1.default.warning((0, common_tags_1.stripIndent)(`
|
|
25
|
+
You are currently using a prerelease version of Node (${version}), which is not supported.
|
|
26
|
+
You can use this for testing, but we do not recommend it in production.
|
|
27
|
+
Before reporting any bugs, please test with a supported version of Node (>=${MIN_NODE_VERSION}).
|
|
28
|
+
`));
|
|
29
|
+
}
|
|
30
|
+
process.on('unhandledRejection', (reason) => {
|
|
31
|
+
// This will exit the process in newer Node anyway so lets be consistent
|
|
32
|
+
// across versions and crash
|
|
33
|
+
// reason can be anything, it can be a message, an object, ANYTHING!
|
|
34
|
+
// we convert it to an error object
|
|
35
|
+
if (!(reason instanceof Error)) {
|
|
36
|
+
reason = new Error(util_1.default.format(reason));
|
|
37
|
+
}
|
|
38
|
+
logger_1.default.panic('UNHANDLED REJECTION', reason);
|
|
39
|
+
});
|
|
40
|
+
process.on('uncaughtException', (error) => {
|
|
41
|
+
logger_1.default.panic('UNHANDLED EXCEPTION', error);
|
|
42
|
+
});
|
|
43
|
+
process.on('exit', (code) => {
|
|
44
|
+
logger_1.default.message(`Exit with code: ${code}`);
|
|
45
|
+
});
|
|
46
|
+
(0, create_cli_1.createCli)(process.argv);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const signal_exit_1 = __importDefault(require("signal-exit"));
|
|
7
|
+
const controllable_script_1 = require("../../common/child-process/controllable-script");
|
|
8
|
+
function default_1(config) {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const build = new controllable_script_1.ControllableScript(`
|
|
11
|
+
const {buildLibrary} = require(${JSON.stringify(require.resolve('../../common/library'))});
|
|
12
|
+
buildLibrary({
|
|
13
|
+
lib: ${JSON.stringify(config.lib)},
|
|
14
|
+
newJsxTransform: ${JSON.stringify(config.newJsxTransform)}
|
|
15
|
+
});
|
|
16
|
+
`, null);
|
|
17
|
+
build.start();
|
|
18
|
+
build.onExit((code) => {
|
|
19
|
+
if (code) {
|
|
20
|
+
reject(new Error('Error build library'));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
resolve(true);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
process.on('SIGINT', async () => {
|
|
27
|
+
await build.stop('SIGINT');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
});
|
|
30
|
+
process.on('SIGTERM', async () => {
|
|
31
|
+
await build.stop('SIGTERM');
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
(0, signal_exit_1.default)((_code, signal) => {
|
|
35
|
+
build.stop(signal);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildClient = void 0;
|
|
4
|
+
const compile_1 = require("../../../common/webpack/compile");
|
|
5
|
+
function buildClient(config) {
|
|
6
|
+
return (0, compile_1.webpackCompile)(config.client);
|
|
7
|
+
}
|
|
8
|
+
exports.buildClient = buildClient;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
const utils_1 = require("../../../common/utils");
|
|
27
|
+
function default_1(config) {
|
|
28
|
+
const shouldCompileClient = (0, utils_1.shouldCompileTarget)(config.target, 'client');
|
|
29
|
+
const shouldCompileServer = (0, utils_1.shouldCompileTarget)(config.target, 'server');
|
|
30
|
+
const compilations = [];
|
|
31
|
+
if (shouldCompileClient) {
|
|
32
|
+
compilations.push((async () => {
|
|
33
|
+
const { buildClient } = await Promise.resolve().then(() => __importStar(require('./client')));
|
|
34
|
+
return buildClient(config);
|
|
35
|
+
})());
|
|
36
|
+
}
|
|
37
|
+
if (shouldCompileServer) {
|
|
38
|
+
compilations.push((async () => {
|
|
39
|
+
const { buildServer } = await Promise.resolve().then(() => __importStar(require('./server')));
|
|
40
|
+
return buildServer(config);
|
|
41
|
+
})());
|
|
42
|
+
}
|
|
43
|
+
// createRunFolder();
|
|
44
|
+
return Promise.all(compilations);
|
|
45
|
+
}
|
|
46
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildServer = void 0;
|
|
7
|
+
const signal_exit_1 = __importDefault(require("signal-exit"));
|
|
8
|
+
const controllable_script_1 = require("../../../common/child-process/controllable-script");
|
|
9
|
+
const paths_1 = __importDefault(require("../../../common/paths"));
|
|
10
|
+
const utils_1 = require("../../../common/utils");
|
|
11
|
+
function buildServer(config) {
|
|
12
|
+
(0, utils_1.createRunFolder)();
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const build = new controllable_script_1.ControllableScript(`
|
|
15
|
+
const ts = require('typescript');
|
|
16
|
+
const {Logger} = require(${JSON.stringify(require.resolve('../../../common/logger'))});
|
|
17
|
+
const {compile} = require(${JSON.stringify(require.resolve('../../../common/typescript/compile'))});
|
|
18
|
+
|
|
19
|
+
const logger = new Logger('server', ${config.verbose});
|
|
20
|
+
compile(ts, ${JSON.stringify(paths_1.default.appServer)}, {logger});
|
|
21
|
+
`, null);
|
|
22
|
+
build.start();
|
|
23
|
+
build.onExit((code) => {
|
|
24
|
+
if (code) {
|
|
25
|
+
reject(new Error('Error compile server'));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
resolve();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
process.on('SIGINT', async () => {
|
|
32
|
+
await build.stop('SIGINT');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
35
|
+
process.on('SIGTERM', async () => {
|
|
36
|
+
await build.stop('SIGTERM');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
(0, signal_exit_1.default)((_code, signal) => {
|
|
40
|
+
build.stop(signal);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.buildServer = buildServer;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 _a;
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
const models_1 = require("../../common/models");
|
|
28
|
+
async function default_1(config) {
|
|
29
|
+
process.env.NODE_ENV = 'production';
|
|
30
|
+
const { default: build } = await (_a = (0, models_1.isLibraryConfig)(config) ? './build-lib' : './build-service', Promise.resolve().then(() => __importStar(require(_a))));
|
|
31
|
+
return build(config);
|
|
32
|
+
}
|
|
33
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.watchClientCompilation = void 0;
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const fs_1 = __importDefault(require("fs"));
|
|
20
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
21
|
+
const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
|
|
22
|
+
const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
|
|
23
|
+
const paths_1 = __importDefault(require("../../common/paths"));
|
|
24
|
+
const logger_1 = require("../../common/logger");
|
|
25
|
+
const config_1 = require("../../common/webpack/config");
|
|
26
|
+
async function watchClientCompilation(config, onCompilationEnd) {
|
|
27
|
+
const clientCompilation = await buildWebpackServer(config);
|
|
28
|
+
const { afterEmit } = (0, webpack_manifest_plugin_1.getCompilerHooks)(clientCompilation.compiler);
|
|
29
|
+
afterEmit.tap('app-builder: afterEmit', onCompilationEnd);
|
|
30
|
+
return clientCompilation;
|
|
31
|
+
}
|
|
32
|
+
exports.watchClientCompilation = watchClientCompilation;
|
|
33
|
+
async function buildWebpackServer(config) {
|
|
34
|
+
const logger = new logger_1.Logger('webpack', config.verbose);
|
|
35
|
+
const _a = config.client.devServer || {}, { webSocketPath = path_1.default.normalize(`/${config.client.publicPathPrefix}/build/sockjs-node`) } = _a, devServer = __rest(_a, ["webSocketPath"]);
|
|
36
|
+
const normalizedConfig = Object.assign(Object.assign({}, config.client), { devServer: Object.assign(Object.assign({}, devServer), { webSocketPath }) });
|
|
37
|
+
const webpackConfig = (0, config_1.webpackConfigFactory)("development" /* WebpackMode.Dev */, normalizedConfig, { logger });
|
|
38
|
+
const options = Object.assign({ static: path_1.default.resolve(paths_1.default.appDist, 'public'), devMiddleware: {
|
|
39
|
+
publicPath: path_1.default.normalize(config.client.publicPathPrefix + '/build/'),
|
|
40
|
+
stats: 'errors-warnings',
|
|
41
|
+
}, liveReload: false, hot: true, client: {
|
|
42
|
+
webSocketURL: { pathname: webSocketPath },
|
|
43
|
+
overlay: {
|
|
44
|
+
warnings: config.verbose,
|
|
45
|
+
},
|
|
46
|
+
}, webSocketServer: {
|
|
47
|
+
options: {
|
|
48
|
+
path: webSocketPath,
|
|
49
|
+
},
|
|
50
|
+
}, host: '0.0.0.0', allowedHosts: 'all', headers: {
|
|
51
|
+
'Access-Control-Allow-Origin': '*',
|
|
52
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
53
|
+
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
|
|
54
|
+
} }, devServer);
|
|
55
|
+
let listenOn = options.port || options.ipc;
|
|
56
|
+
if (!listenOn) {
|
|
57
|
+
listenOn = path_1.default.resolve(paths_1.default.appDist, 'run/client.sock');
|
|
58
|
+
options.ipc = listenOn;
|
|
59
|
+
}
|
|
60
|
+
if (config.client.lazyCompilation) {
|
|
61
|
+
options.proxy = Object.assign(Object.assign({}, options.proxy), { '/build/lazy': {
|
|
62
|
+
target: `http://localhost:${config.client.lazyCompilation.port}`,
|
|
63
|
+
pathRewrite: { '^/build/lazy': '' },
|
|
64
|
+
} });
|
|
65
|
+
}
|
|
66
|
+
if (config.server.port) {
|
|
67
|
+
options.proxy = Object.assign(Object.assign({}, options.proxy), { '/': {
|
|
68
|
+
target: `http://localhost:${config.server.port}`,
|
|
69
|
+
bypass: (req) => {
|
|
70
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const pathname = req.path.replace(/^\//, '');
|
|
74
|
+
const filepath = path_1.default.resolve(paths_1.default.appDist, 'public', pathname);
|
|
75
|
+
if (!fs_1.default.existsSync(filepath)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const stat = fs_1.default.statSync(filepath);
|
|
79
|
+
if (!stat.isFile()) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return req.path;
|
|
83
|
+
},
|
|
84
|
+
} });
|
|
85
|
+
}
|
|
86
|
+
const compiler = (0, webpack_1.default)(webpackConfig);
|
|
87
|
+
const server = new webpack_dev_server_1.default(options, compiler);
|
|
88
|
+
try {
|
|
89
|
+
await server.start();
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
logger.logError(e);
|
|
93
|
+
}
|
|
94
|
+
if (options.ipc && typeof options.ipc === 'string') {
|
|
95
|
+
fs_1.default.chmod(options.ipc, 0o666, (e) => logger.logError('', e));
|
|
96
|
+
}
|
|
97
|
+
return server;
|
|
98
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
const nodemon_1 = __importDefault(require("nodemon"));
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const signal_exit_1 = __importDefault(require("signal-exit"));
|
|
32
|
+
const utils_1 = require("../../common/utils");
|
|
33
|
+
const logger_1 = __importDefault(require("../../common/logger"));
|
|
34
|
+
const paths_1 = __importDefault(require("../../common/paths"));
|
|
35
|
+
async function default_1(config) {
|
|
36
|
+
process.env.NODE_ENV = 'development';
|
|
37
|
+
const shouldCompileClient = (0, utils_1.shouldCompileTarget)(config.target, 'client');
|
|
38
|
+
const shouldCompileServer = (0, utils_1.shouldCompileTarget)(config.target, 'server');
|
|
39
|
+
let clientCompiled = !shouldCompileClient;
|
|
40
|
+
let serverCompiled = !shouldCompileServer;
|
|
41
|
+
let needToStartNodemon = shouldCompileServer;
|
|
42
|
+
const serverPath = path_1.default.resolve(paths_1.default.appDist, 'server');
|
|
43
|
+
const { inspect, inspectBrk } = config.server;
|
|
44
|
+
const startNodemon = () => {
|
|
45
|
+
var _a;
|
|
46
|
+
if (needToStartNodemon && serverCompiled && clientCompiled) {
|
|
47
|
+
logger_1.default.message('Starting application at', serverPath);
|
|
48
|
+
const serverWatch = (_a = config.server.watch) !== null && _a !== void 0 ? _a : [];
|
|
49
|
+
const delay = config.server.watchThrottle;
|
|
50
|
+
const nodemonInstance = (0, nodemon_1.default)({
|
|
51
|
+
ext: 'js json',
|
|
52
|
+
script: `${serverPath}/index.js`,
|
|
53
|
+
args: ['--dev', config.server.port ? `--port=${config.server.port}` : ''],
|
|
54
|
+
nodeArgs: inspect || inspectBrk
|
|
55
|
+
? [`--${inspect ? 'inspect' : 'inspect-brk'}=:::${inspect || inspectBrk}`]
|
|
56
|
+
: undefined,
|
|
57
|
+
watch: [serverPath, ...serverWatch],
|
|
58
|
+
delay,
|
|
59
|
+
});
|
|
60
|
+
nodemonInstance.on('quit', () => process.exit());
|
|
61
|
+
needToStartNodemon = false;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
let serverCompilation;
|
|
65
|
+
if (shouldCompileServer) {
|
|
66
|
+
const { watchServerCompilation } = await Promise.resolve().then(() => __importStar(require('./server')));
|
|
67
|
+
serverCompilation = watchServerCompilation(config);
|
|
68
|
+
serverCompilation.onMessage((msg) => {
|
|
69
|
+
if (msg.type === 'Emitted') {
|
|
70
|
+
serverCompiled = true;
|
|
71
|
+
startNodemon();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
let clientCompilation;
|
|
76
|
+
if (shouldCompileClient) {
|
|
77
|
+
const { watchClientCompilation } = await Promise.resolve().then(() => __importStar(require('./client')));
|
|
78
|
+
clientCompilation = await watchClientCompilation(config, () => {
|
|
79
|
+
logger_1.default.success('Manifest was compiled successfully');
|
|
80
|
+
clientCompiled = true;
|
|
81
|
+
startNodemon();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
process.on('SIGINT', async () => {
|
|
85
|
+
logger_1.default.success('\nCleaning up...');
|
|
86
|
+
await (serverCompilation === null || serverCompilation === void 0 ? void 0 : serverCompilation.stop('SIGINT'));
|
|
87
|
+
await (clientCompilation === null || clientCompilation === void 0 ? void 0 : clientCompilation.stop());
|
|
88
|
+
process.exit(1);
|
|
89
|
+
});
|
|
90
|
+
process.on('SIGTERM', async () => {
|
|
91
|
+
logger_1.default.success('\nCleaning up...');
|
|
92
|
+
await (serverCompilation === null || serverCompilation === void 0 ? void 0 : serverCompilation.stop('SIGTERM'));
|
|
93
|
+
await (clientCompilation === null || clientCompilation === void 0 ? void 0 : clientCompilation.stop());
|
|
94
|
+
process.exit(1);
|
|
95
|
+
});
|
|
96
|
+
(0, signal_exit_1.default)((_code, signal) => {
|
|
97
|
+
serverCompilation === null || serverCompilation === void 0 ? void 0 : serverCompilation.stop(signal);
|
|
98
|
+
clientCompilation === null || clientCompilation === void 0 ? void 0 : clientCompilation.stop();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.watchServerCompilation = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const rimraf_1 = __importDefault(require("rimraf"));
|
|
9
|
+
const controllable_script_1 = require("../../common/child-process/controllable-script");
|
|
10
|
+
const utils_1 = require("../../common/utils");
|
|
11
|
+
const paths_1 = __importDefault(require("../../common/paths"));
|
|
12
|
+
function watchServerCompilation(config) {
|
|
13
|
+
const serverPath = path_1.default.resolve(paths_1.default.appDist, 'server');
|
|
14
|
+
rimraf_1.default.sync(serverPath);
|
|
15
|
+
rimraf_1.default.sync(paths_1.default.appRun);
|
|
16
|
+
(0, utils_1.createRunFolder)();
|
|
17
|
+
const build = new controllable_script_1.ControllableScript(`
|
|
18
|
+
const ts = require('typescript');
|
|
19
|
+
const {Logger} = require(${JSON.stringify(require.resolve('../../common/logger'))});
|
|
20
|
+
const {watch} = require(${JSON.stringify(require.resolve('../../common/typescript/watch'))});
|
|
21
|
+
|
|
22
|
+
const logger = new Logger('server', ${config.verbose});
|
|
23
|
+
watch(
|
|
24
|
+
ts,
|
|
25
|
+
${JSON.stringify(paths_1.default.appServer)},
|
|
26
|
+
{
|
|
27
|
+
logger,
|
|
28
|
+
onAfterFilesEmitted: () => {
|
|
29
|
+
process.send({type: 'Emitted'});
|
|
30
|
+
},
|
|
31
|
+
enableSourceMap: ${config.server.inspect || config.server.inspectBrk ? 'true' : 'false'}
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
`, null);
|
|
35
|
+
build.start();
|
|
36
|
+
return build;
|
|
37
|
+
}
|
|
38
|
+
exports.watchServerCompilation = watchServerCompilation;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function babelPreset(config: {
|
|
2
|
+
newJsxTransform?: boolean;
|
|
3
|
+
}): (string | {
|
|
4
|
+
env: {
|
|
5
|
+
modules: boolean;
|
|
6
|
+
bugfixes: boolean;
|
|
7
|
+
};
|
|
8
|
+
runtime: {
|
|
9
|
+
version: string;
|
|
10
|
+
};
|
|
11
|
+
typescript: boolean;
|
|
12
|
+
react: {
|
|
13
|
+
runtime: string;
|
|
14
|
+
};
|
|
15
|
+
})[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.babelPreset = void 0;
|
|
4
|
+
function babelPreset(config) {
|
|
5
|
+
return [
|
|
6
|
+
require.resolve('./ui-preset'),
|
|
7
|
+
{
|
|
8
|
+
env: { modules: false, bugfixes: true },
|
|
9
|
+
runtime: { version: '^7.13.10' },
|
|
10
|
+
typescript: true,
|
|
11
|
+
react: {
|
|
12
|
+
runtime: config.newJsxTransform ? 'automatic' : 'classic',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
exports.babelPreset = babelPreset;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare function getOption<T>(value: T, defaultValue: T): T;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function getOption(value, defaultValue) {
|
|
3
|
+
if (typeof value === 'undefined') {
|
|
4
|
+
return defaultValue;
|
|
5
|
+
}
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
module.exports = function (_context, options = {}) {
|
|
9
|
+
const env = process.env.BABEL_ENV || process.env.NODE_ENV || 'development';
|
|
10
|
+
const isEnvDevelopment = env === 'development';
|
|
11
|
+
const isEnvProduction = env === 'production';
|
|
12
|
+
const isEnvTest = env === 'test';
|
|
13
|
+
const envOptions = getOption(options.env, {});
|
|
14
|
+
const runtimeOptions = getOption(options.runtime, {});
|
|
15
|
+
const isTypeScriptEnabled = getOption(options.typescript, false);
|
|
16
|
+
const reactOptions = getOption(options.react, {});
|
|
17
|
+
const presets = [
|
|
18
|
+
// Latest stable ECMAScript features
|
|
19
|
+
(isEnvDevelopment || isEnvProduction) && [require.resolve('@babel/preset-env'), envOptions],
|
|
20
|
+
// ES features necessary for current Node version
|
|
21
|
+
isEnvTest && [
|
|
22
|
+
require.resolve('@babel/preset-env'),
|
|
23
|
+
Object.assign({}, envOptions, {
|
|
24
|
+
targets: {
|
|
25
|
+
node: 'current',
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
// JSX
|
|
30
|
+
[
|
|
31
|
+
require.resolve('@babel/preset-react'),
|
|
32
|
+
Object.assign({}, reactOptions, {
|
|
33
|
+
development: isEnvDevelopment || isEnvTest,
|
|
34
|
+
useBuiltIns: true,
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
isTypeScriptEnabled && [
|
|
38
|
+
require.resolve('@babel/preset-typescript'),
|
|
39
|
+
{
|
|
40
|
+
allowDeclareFields: true,
|
|
41
|
+
optimizeConstEnums: true,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
].filter(Boolean);
|
|
45
|
+
const plugins = [
|
|
46
|
+
isTypeScriptEnabled && [
|
|
47
|
+
require.resolve('@babel/plugin-proposal-decorators'),
|
|
48
|
+
{
|
|
49
|
+
// @decorator
|
|
50
|
+
// export class Foo {}
|
|
51
|
+
decoratorsBeforeExport: true,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
// Polyfills the runtime needed for async/await and generators
|
|
55
|
+
[require.resolve('@babel/plugin-transform-runtime'), runtimeOptions],
|
|
56
|
+
isEnvProduction && [
|
|
57
|
+
require.resolve('babel-plugin-transform-react-remove-prop-types'),
|
|
58
|
+
{
|
|
59
|
+
removeImport: true,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
].filter(Boolean);
|
|
63
|
+
return {
|
|
64
|
+
assumptions: {
|
|
65
|
+
setPublicClassFields: true,
|
|
66
|
+
privateFieldsAsProperties: true,
|
|
67
|
+
},
|
|
68
|
+
presets,
|
|
69
|
+
plugins,
|
|
70
|
+
};
|
|
71
|
+
};
|