@proteinjs/server 2.1.9 → 3.0.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 +25 -0
- package/LICENSE +21 -0
- package/dist/generated/index.d.ts +0 -16
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +1 -17
- package/dist/generated/index.js.map +1 -1
- package/dist/src/startServer.d.ts.map +1 -1
- package/dist/src/startServer.js +48 -15
- package/dist/src/startServer.js.map +1 -1
- package/generated/index.ts +7 -26
- package/package.json +6 -25
- package/src/startServer.ts +51 -15
- package/dist/src/nodeModulesPath.d.ts +0 -3
- package/dist/src/nodeModulesPath.d.ts.map +0 -1
- package/dist/src/nodeModulesPath.js +0 -8
- package/dist/src/nodeModulesPath.js.map +0 -1
- package/dist/webpack.config.d.ts +0 -82
- package/dist/webpack.config.d.ts.map +0 -1
- package/dist/webpack.config.js +0 -130
- package/dist/webpack.config.js.map +0 -1
- package/src/nodeModulesPath.ts +0 -5
- package/webpack.config.js +0 -131
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0](https://github.com/proteinjs/server/compare/@proteinjs/server@2.1.10...@proteinjs/server@3.0.0) (2025-11-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* feat!: Server now constructs hot client builds entirely from the consumer's webpack config and node_modules. ([bf9a7dd](https://github.com/proteinjs/server/commit/bf9a7dddbbfa2d0f3b9ad6b4a54fb706dd0dab2b))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* Added required `ServerConfig.hotClientBuilds.webpackConfigPath` prop to enable hot client builds.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [2.1.10](https://github.com/proteinjs/server/compare/@proteinjs/server@2.1.9...@proteinjs/server@2.1.10) (2025-11-15)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* Add `vm-browserify` ([be37a17](https://github.com/proteinjs/server/commit/be37a17e17b730dd8915d93e1b9c679894744d69))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
6
31
|
## [2.1.7](https://github.com/proteinjs/server/compare/@proteinjs/server@2.1.6...@proteinjs/server@2.1.7) (2025-08-13)
|
|
7
32
|
|
|
8
33
|
**Note:** Version bump only for package @proteinjs/server
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Brent Bahry
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,36 +1,20 @@
|
|
|
1
1
|
/** Load Dependency Source Graphs */
|
|
2
|
-
import '@pmmmwh/react-refresh-webpack-plugin';
|
|
3
2
|
import '@proteinjs/event';
|
|
4
3
|
import '@proteinjs/logger';
|
|
5
4
|
import '@proteinjs/reflection';
|
|
6
5
|
import '@proteinjs/server-api';
|
|
7
6
|
import '@proteinjs/util-node';
|
|
8
7
|
import 'body-parser';
|
|
9
|
-
import 'buffer';
|
|
10
8
|
import 'cookie-parser';
|
|
11
|
-
import 'crypto-browserify';
|
|
12
|
-
import 'css-loader';
|
|
13
9
|
import 'events';
|
|
14
10
|
import 'express';
|
|
15
11
|
import 'express-session';
|
|
16
|
-
import 'file-loader';
|
|
17
12
|
import 'passport';
|
|
18
13
|
import 'passport-local';
|
|
19
|
-
import 'path-browserify';
|
|
20
14
|
import 'process';
|
|
21
15
|
import 'react';
|
|
22
16
|
import 'react-helmet';
|
|
23
|
-
import 'react-refresh';
|
|
24
|
-
import 'react-refresh-typescript';
|
|
25
17
|
import 'socket.io';
|
|
26
|
-
import 'stream-browserify';
|
|
27
|
-
import 'style-loader';
|
|
28
|
-
import 'ts-loader';
|
|
29
18
|
import 'typescript';
|
|
30
|
-
import 'url';
|
|
31
|
-
import 'util';
|
|
32
|
-
import 'webpack';
|
|
33
|
-
import 'webpack-dev-middleware';
|
|
34
|
-
import 'webpack-hot-middleware';
|
|
35
19
|
export * from '../index';
|
|
36
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,aAAa,CAAC;AACrB,OAAO,eAAe,CAAC;AACvB,OAAO,QAAQ,CAAC;AAChB,OAAO,SAAS,CAAC;AACjB,OAAO,iBAAiB,CAAC;AACzB,OAAO,UAAU,CAAC;AAClB,OAAO,gBAAgB,CAAC;AACxB,OAAO,SAAS,CAAC;AACjB,OAAO,OAAO,CAAC;AACf,OAAO,cAAc,CAAC;AACtB,OAAO,WAAW,CAAC;AACnB,OAAO,YAAY,CAAC;AA6BpB,cAAc,UAAU,CAAC"}
|
package/dist/generated/index.js
CHANGED
|
@@ -15,41 +15,25 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
require("@pmmmwh/react-refresh-webpack-plugin");
|
|
19
18
|
require("@proteinjs/event");
|
|
20
19
|
require("@proteinjs/logger");
|
|
21
20
|
require("@proteinjs/reflection");
|
|
22
21
|
require("@proteinjs/server-api");
|
|
23
22
|
require("@proteinjs/util-node");
|
|
24
23
|
require("body-parser");
|
|
25
|
-
require("buffer");
|
|
26
24
|
require("cookie-parser");
|
|
27
|
-
require("crypto-browserify");
|
|
28
|
-
require("css-loader");
|
|
29
25
|
require("events");
|
|
30
26
|
require("express");
|
|
31
27
|
require("express-session");
|
|
32
|
-
require("file-loader");
|
|
33
28
|
require("passport");
|
|
34
29
|
require("passport-local");
|
|
35
|
-
require("path-browserify");
|
|
36
30
|
require("process");
|
|
37
31
|
require("react");
|
|
38
32
|
require("react-helmet");
|
|
39
|
-
require("react-refresh");
|
|
40
|
-
require("react-refresh-typescript");
|
|
41
33
|
require("socket.io");
|
|
42
|
-
require("stream-browserify");
|
|
43
|
-
require("style-loader");
|
|
44
|
-
require("ts-loader");
|
|
45
34
|
require("typescript");
|
|
46
|
-
require("url");
|
|
47
|
-
require("util");
|
|
48
|
-
require("webpack");
|
|
49
|
-
require("webpack-dev-middleware");
|
|
50
|
-
require("webpack-hot-middleware");
|
|
51
35
|
/** Generate Source Graph */
|
|
52
|
-
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/server/NodeGlobalDataStorage\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"NodeGlobalDataStorage\",\"filePath\":\"/
|
|
36
|
+
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/server/NodeGlobalDataStorage\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"NodeGlobalDataStorage\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/NodeGlobalDataStorage.ts\",\"qualifiedName\":\"@proteinjs/server/NodeGlobalDataStorage\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"HOOK_INITIALIZED\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"GLOBAL_DATA\",\"type\":{\"packageName\":\"@proteinjs/server\",\"name\":\"{ [id: string]: GlobalData }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server/{ [id: string]: GlobalData }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"environment\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"setData\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"data\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"GlobalData\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/GlobalData\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"getData\",\"returnType\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"GlobalData\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/GlobalData\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"initHook\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"GlobalDataStorage\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/GlobalDataStorage\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/server-api/GlobalDataStorage\"},{\"v\":\"@proteinjs/server/NodeSessionDataStorage\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"NodeSessionDataStorage\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/NodeSessionDataStorage.ts\",\"qualifiedName\":\"@proteinjs/server/NodeSessionDataStorage\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"HOOK_INITIALIZED\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"SESSION_DATA\",\"type\":{\"packageName\":\"@proteinjs/server\",\"name\":\"{ [id: string]: SessionData }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server/{ [id: string]: SessionData }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"environment\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"setData\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"data\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"SessionData\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/SessionData\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"getData\",\"returnType\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"SessionData\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/SessionData\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"initHook\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"SessionDataStorage\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/SessionDataStorage\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/server-api/SessionDataStorage\"},{\"v\":\"@proteinjs/server/ExtendedIncomingMessage\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"ExtendedIncomingMessage\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/SocketIOServerRepo.ts\",\"qualifiedName\":\"@proteinjs/server/ExtendedIncomingMessage\",\"properties\":[{\"name\":\"sessionID\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"user\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"http\",\"name\":\"IncomingMessage\",\"filePath\":null,\"qualifiedName\":\"http/IncomingMessage\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"http/IncomingMessage\"},{\"v\":\"@proteinjs/server/ExtendedSocket\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"ExtendedSocket\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/SocketIOServerRepo.ts\",\"qualifiedName\":\"@proteinjs/server/ExtendedSocket\",\"properties\":[{\"name\":\"request\",\"type\":{\"packageName\":\"@proteinjs/server\",\"name\":\"ExtendedIncomingMessage\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server/ExtendedIncomingMessage\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"socket.io\",\"name\":\"Socket\",\"filePath\":null,\"qualifiedName\":\"socket.io/Socket\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"socket.io/Socket\"},{\"v\":\"@proteinjs/server/environmentCache\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"environmentCache\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/envCache.ts\",\"qualifiedName\":\"@proteinjs/server/environmentCache\",\"type\":{\"packageName\":\"\",\"name\":\"GlobalDataCache<Env>\",\"filePath\":null,\"qualifiedName\":\"/GlobalDataCache<Env>\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"GlobalDataCache\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/GlobalDataCache\",\"typeParameters\":[\"@proteinjs/server-api/Env\"],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/server-api/GlobalDataCache\"},{\"v\":\"@proteinjs/server/healthCheck\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"healthCheck\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/routes/healthCheck.ts\",\"qualifiedName\":\"@proteinjs/server/healthCheck\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/server-api/Route\"}],\"edges\":[{\"v\":\"@proteinjs/server/NodeGlobalDataStorage\",\"w\":\"@proteinjs/server-api/GlobalDataStorage\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/server/NodeSessionDataStorage\",\"w\":\"@proteinjs/server-api/SessionDataStorage\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/server/ExtendedIncomingMessage\",\"w\":\"http/IncomingMessage\",\"value\":\"extends interface\"},{\"v\":\"@proteinjs/server/ExtendedSocket\",\"w\":\"socket.io/Socket\",\"value\":\"extends interface\"},{\"v\":\"@proteinjs/server/environmentCache\",\"w\":\"@proteinjs/server-api/GlobalDataCache\",\"value\":\"has type\"},{\"v\":\"@proteinjs/server/healthCheck\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"}]}";
|
|
53
37
|
/** Generate Source Links */
|
|
54
38
|
var NodeGlobalDataStorage_1 = require("../src/NodeGlobalDataStorage");
|
|
55
39
|
var NodeSessionDataStorage_1 = require("../src/NodeSessionDataStorage");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,4BAA0B;AAC1B,6BAA2B;AAC3B,iCAA+B;AAC/B,iCAA+B;AAC/B,gCAA8B;AAC9B,uBAAqB;AACrB,yBAAuB;AACvB,kBAAgB;AAChB,mBAAiB;AACjB,2BAAyB;AACzB,oBAAkB;AAClB,0BAAwB;AACxB,mBAAiB;AACjB,iBAAe;AACf,wBAAsB;AACtB,qBAAmB;AACnB,sBAAoB;AAGpB,4BAA4B;AAE5B,IAAM,WAAW,GAAG,gqRAAgqR,CAAC;AAGrrR,4BAA4B;AAE5B,sEAAqE;AACrE,wEAAuE;AACvE,4CAAmD;AACnD,yDAAwD;AAExD,IAAM,WAAW,GAAG;IACnB,yCAAyC,EAAE,6CAAqB;IAChE,0CAA0C,EAAE,+CAAsB;IAClE,oCAAoC,EAAE,2BAAgB;IACtD,+BAA+B,EAAE,yBAAW;CAC5C,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startServer.d.ts","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"startServer.d.ts","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":"AASA,OAAO,EAGL,YAAY,EAKb,MAAM,uBAAuB,CAAC;AAU/B,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,iBAwCrD"}
|
package/dist/src/startServer.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -40,20 +51,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
51
|
};
|
|
41
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
53
|
exports.startServer = void 0;
|
|
54
|
+
var path_1 = __importDefault(require("path"));
|
|
55
|
+
var module_1 = require("module");
|
|
43
56
|
var express_1 = __importDefault(require("express"));
|
|
44
57
|
var express_session_1 = __importDefault(require("express-session"));
|
|
45
58
|
var cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
46
59
|
var body_parser_1 = __importDefault(require("body-parser"));
|
|
47
60
|
var passport_1 = __importDefault(require("passport"));
|
|
48
61
|
var passport_local_1 = __importDefault(require("passport-local"));
|
|
49
|
-
var webpack_1 = __importDefault(require("webpack"));
|
|
50
|
-
var webpack_dev_middleware_1 = __importDefault(require("webpack-dev-middleware"));
|
|
51
|
-
var webpack_hot_middleware_1 = __importDefault(require("webpack-hot-middleware"));
|
|
52
62
|
var http_1 = require("http");
|
|
53
63
|
var server_api_1 = require("@proteinjs/server-api");
|
|
54
64
|
var loadRoutes_1 = require("./loadRoutes");
|
|
55
65
|
var logger_1 = require("@proteinjs/logger");
|
|
56
|
-
var nodeModulesPath_1 = require("./nodeModulesPath");
|
|
57
66
|
var SocketIOServerRepo_1 = require("./SocketIOServerRepo");
|
|
58
67
|
var staticContentPath = '/static/';
|
|
59
68
|
var logger = new logger_1.Logger({ name: 'Server' });
|
|
@@ -167,28 +176,52 @@ function configureRequests(app) {
|
|
|
167
176
|
}
|
|
168
177
|
function initializeHotReloading(app, config) {
|
|
169
178
|
var _a, _b;
|
|
179
|
+
// Enable only in dev with all required settings present
|
|
170
180
|
if (!process.env.DEVELOPMENT ||
|
|
171
181
|
process.env.DISABLE_HOT_CLIENT_BUILDS ||
|
|
172
182
|
!config.hotClientBuilds ||
|
|
183
|
+
!config.hotClientBuilds.nodeModulesPath ||
|
|
184
|
+
!config.hotClientBuilds.webpackConfigPath ||
|
|
173
185
|
!((_a = config.staticContent) === null || _a === void 0 ? void 0 : _a.staticContentDir) ||
|
|
174
186
|
!((_b = config.staticContent) === null || _b === void 0 ? void 0 : _b.appEntryPath)) {
|
|
175
187
|
return;
|
|
176
188
|
}
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
var
|
|
182
|
-
|
|
189
|
+
var appRequire = makeAppRequire(config.hotClientBuilds.nodeModulesPath);
|
|
190
|
+
// Load webpack & middlewares from the consumer app
|
|
191
|
+
var webpack = appRequire('webpack');
|
|
192
|
+
var webpackDevMiddleware = appRequire('webpack-dev-middleware');
|
|
193
|
+
var webpackHotMiddleware = appRequire('webpack-hot-middleware');
|
|
194
|
+
var devConfig = createWebpackConfigOverlay(config, webpack);
|
|
195
|
+
var compiler = webpack(devConfig);
|
|
196
|
+
app.use(webpackDevMiddleware(compiler, {
|
|
183
197
|
publicPath: staticContentPath,
|
|
184
198
|
}));
|
|
185
|
-
app.use((
|
|
199
|
+
app.use(webpackHotMiddleware(compiler));
|
|
186
200
|
}
|
|
187
|
-
|
|
201
|
+
// Resolve modules (webpack + middlewares) from the consumer’s node_modules
|
|
202
|
+
function makeAppRequire(nodeModulesPath) {
|
|
203
|
+
// Any file under the consumer's node_modules works as a base for createRequire
|
|
204
|
+
return (0, module_1.createRequire)(path_1.default.join(nodeModulesPath, '__app_require__.js'));
|
|
205
|
+
}
|
|
206
|
+
function createWebpackConfigOverlay(config, webpack) {
|
|
188
207
|
var _a;
|
|
189
|
-
|
|
190
|
-
var
|
|
191
|
-
|
|
208
|
+
// Load the consumer webpack config (CommonJS). If it exports a function, call with { mode: 'development' }.
|
|
209
|
+
var consumerExport = require(config.hotClientBuilds.webpackConfigPath);
|
|
210
|
+
var baseConfig = typeof consumerExport === 'function' ? consumerExport({ mode: 'development' }) : consumerExport;
|
|
211
|
+
var devConfig = __assign({}, baseConfig);
|
|
212
|
+
devConfig.mode = 'development';
|
|
213
|
+
// Inject HMR client + the consumer's entrypoint (absolute path already provided)
|
|
214
|
+
// Keep it minimal: no query params; defaults are fine.
|
|
215
|
+
devConfig.entry = { app: ['webpack-hot-middleware/client', config.staticContent.appEntryPath] };
|
|
216
|
+
// Ensure bundles are served from memory at /static/, and set a concrete path for plugins that read it.
|
|
217
|
+
devConfig.output = __assign(__assign({}, (baseConfig.output || {})), { publicPath: staticContentPath, path: config.staticContent.staticContentDir });
|
|
218
|
+
// Ensure HMR plugin exists (idempotent)
|
|
219
|
+
devConfig.plugins = (_a = devConfig.plugins) !== null && _a !== void 0 ? _a : [];
|
|
220
|
+
var hasHmr = devConfig.plugins.some(function (p) { var _a; return ((_a = p === null || p === void 0 ? void 0 : p.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'HotModuleReplacementPlugin'; });
|
|
221
|
+
if (!hasHmr) {
|
|
222
|
+
devConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
|
|
223
|
+
}
|
|
224
|
+
return devConfig;
|
|
192
225
|
}
|
|
193
226
|
function configureHttps(app) {
|
|
194
227
|
app.use(function (request, response, next) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startServer.js","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"startServer.js","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":";;;;;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S,CAAC,CAAC;yBACxB;oBACH,CAAC,CAAC,CAAC;;;;;CACJ;AAED,SAAS,KAAK,CAAC,MAAkB,EAAE,MAAoB;IACrD,IAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAClB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;YAC3B,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CAAC;SAC1D;QAED,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,oCAA6B,IAAI,CAAE,EAAE,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/generated/index.ts
CHANGED
|
@@ -1,44 +1,27 @@
|
|
|
1
1
|
/** Load Dependency Source Graphs */
|
|
2
2
|
|
|
3
|
-
import '@pmmmwh/react-refresh-webpack-plugin';
|
|
4
3
|
import '@proteinjs/event';
|
|
5
4
|
import '@proteinjs/logger';
|
|
6
5
|
import '@proteinjs/reflection';
|
|
7
6
|
import '@proteinjs/server-api';
|
|
8
7
|
import '@proteinjs/util-node';
|
|
9
8
|
import 'body-parser';
|
|
10
|
-
import 'buffer';
|
|
11
9
|
import 'cookie-parser';
|
|
12
|
-
import 'crypto-browserify';
|
|
13
|
-
import 'css-loader';
|
|
14
10
|
import 'events';
|
|
15
11
|
import 'express';
|
|
16
12
|
import 'express-session';
|
|
17
|
-
import 'file-loader';
|
|
18
13
|
import 'passport';
|
|
19
14
|
import 'passport-local';
|
|
20
|
-
import 'path-browserify';
|
|
21
15
|
import 'process';
|
|
22
16
|
import 'react';
|
|
23
17
|
import 'react-helmet';
|
|
24
|
-
import 'react-refresh';
|
|
25
|
-
import 'react-refresh-typescript';
|
|
26
18
|
import 'socket.io';
|
|
27
|
-
import 'stream-browserify';
|
|
28
|
-
import 'style-loader';
|
|
29
|
-
import 'ts-loader';
|
|
30
19
|
import 'typescript';
|
|
31
|
-
import 'url';
|
|
32
|
-
import 'util';
|
|
33
|
-
import 'webpack';
|
|
34
|
-
import 'webpack-dev-middleware';
|
|
35
|
-
import 'webpack-hot-middleware';
|
|
36
|
-
|
|
37
20
|
|
|
38
21
|
/** Generate Source Graph */
|
|
39
22
|
|
|
40
|
-
const sourceGraph =
|
|
41
|
-
|
|
23
|
+
const sourceGraph =
|
|
24
|
+
'{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/server/NodeGlobalDataStorage","value":{"packageName":"@proteinjs/server","name":"NodeGlobalDataStorage","filePath":"/home/runner/work/server/server/packages/server/src/NodeGlobalDataStorage.ts","qualifiedName":"@proteinjs/server/NodeGlobalDataStorage","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"HOOK_INITIALIZED","type":null,"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"GLOBAL_DATA","type":{"packageName":"@proteinjs/server","name":"{ [id: string]: GlobalData }","filePath":null,"qualifiedName":"@proteinjs/server/{ [id: string]: GlobalData }","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"environment","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"setData","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"data","type":{"packageName":"@proteinjs/server-api","name":"GlobalData","filePath":null,"qualifiedName":"@proteinjs/server-api/GlobalData","typeParameters":null,"directParents":null}}]},{"name":"getData","returnType":{"packageName":"@proteinjs/server-api","name":"GlobalData","filePath":null,"qualifiedName":"@proteinjs/server-api/GlobalData","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"initHook","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/server-api","name":"GlobalDataStorage","filePath":null,"qualifiedName":"@proteinjs/server-api/GlobalDataStorage","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/server-api/GlobalDataStorage"},{"v":"@proteinjs/server/NodeSessionDataStorage","value":{"packageName":"@proteinjs/server","name":"NodeSessionDataStorage","filePath":"/home/runner/work/server/server/packages/server/src/NodeSessionDataStorage.ts","qualifiedName":"@proteinjs/server/NodeSessionDataStorage","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"HOOK_INITIALIZED","type":null,"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"SESSION_DATA","type":{"packageName":"@proteinjs/server","name":"{ [id: string]: SessionData }","filePath":null,"qualifiedName":"@proteinjs/server/{ [id: string]: SessionData }","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"environment","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"setData","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"data","type":{"packageName":"@proteinjs/server-api","name":"SessionData","filePath":null,"qualifiedName":"@proteinjs/server-api/SessionData","typeParameters":null,"directParents":null}}]},{"name":"getData","returnType":{"packageName":"@proteinjs/server-api","name":"SessionData","filePath":null,"qualifiedName":"@proteinjs/server-api/SessionData","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"initHook","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/server-api","name":"SessionDataStorage","filePath":null,"qualifiedName":"@proteinjs/server-api/SessionDataStorage","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/server-api/SessionDataStorage"},{"v":"@proteinjs/server/ExtendedIncomingMessage","value":{"packageName":"@proteinjs/server","name":"ExtendedIncomingMessage","filePath":"/home/runner/work/server/server/packages/server/src/SocketIOServerRepo.ts","qualifiedName":"@proteinjs/server/ExtendedIncomingMessage","properties":[{"name":"sessionID","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"user","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[],"typeParameters":[],"directParents":[{"packageName":"http","name":"IncomingMessage","filePath":null,"qualifiedName":"http/IncomingMessage","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"sourceType":3}},{"v":"http/IncomingMessage"},{"v":"@proteinjs/server/ExtendedSocket","value":{"packageName":"@proteinjs/server","name":"ExtendedSocket","filePath":"/home/runner/work/server/server/packages/server/src/SocketIOServerRepo.ts","qualifiedName":"@proteinjs/server/ExtendedSocket","properties":[{"name":"request","type":{"packageName":"@proteinjs/server","name":"ExtendedIncomingMessage","filePath":null,"qualifiedName":"@proteinjs/server/ExtendedIncomingMessage","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[],"typeParameters":[],"directParents":[{"packageName":"socket.io","name":"Socket","filePath":null,"qualifiedName":"socket.io/Socket","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"sourceType":3}},{"v":"socket.io/Socket"},{"v":"@proteinjs/server/environmentCache","value":{"packageName":"@proteinjs/server","name":"environmentCache","filePath":"/home/runner/work/server/server/packages/server/src/envCache.ts","qualifiedName":"@proteinjs/server/environmentCache","type":{"packageName":"","name":"GlobalDataCache<Env>","filePath":null,"qualifiedName":"/GlobalDataCache<Env>","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"GlobalDataCache","filePath":null,"qualifiedName":"@proteinjs/server-api/GlobalDataCache","typeParameters":["@proteinjs/server-api/Env"],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/server-api/GlobalDataCache"},{"v":"@proteinjs/server/healthCheck","value":{"packageName":"@proteinjs/server","name":"healthCheck","filePath":"/home/runner/work/server/server/packages/server/src/routes/healthCheck.ts","qualifiedName":"@proteinjs/server/healthCheck","type":{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/server-api/Route"}],"edges":[{"v":"@proteinjs/server/NodeGlobalDataStorage","w":"@proteinjs/server-api/GlobalDataStorage","value":"implements interface"},{"v":"@proteinjs/server/NodeSessionDataStorage","w":"@proteinjs/server-api/SessionDataStorage","value":"implements interface"},{"v":"@proteinjs/server/ExtendedIncomingMessage","w":"http/IncomingMessage","value":"extends interface"},{"v":"@proteinjs/server/ExtendedSocket","w":"socket.io/Socket","value":"extends interface"},{"v":"@proteinjs/server/environmentCache","w":"@proteinjs/server-api/GlobalDataCache","value":"has type"},{"v":"@proteinjs/server/healthCheck","w":"@proteinjs/server-api/Route","value":"has type"}]}';
|
|
42
25
|
|
|
43
26
|
/** Generate Source Links */
|
|
44
27
|
|
|
@@ -48,17 +31,15 @@ import { environmentCache } from '../src/envCache';
|
|
|
48
31
|
import { healthCheck } from '../src/routes/healthCheck';
|
|
49
32
|
|
|
50
33
|
const sourceLinks = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
34
|
+
'@proteinjs/server/NodeGlobalDataStorage': NodeGlobalDataStorage,
|
|
35
|
+
'@proteinjs/server/NodeSessionDataStorage': NodeSessionDataStorage,
|
|
36
|
+
'@proteinjs/server/environmentCache': environmentCache,
|
|
37
|
+
'@proteinjs/server/healthCheck': healthCheck,
|
|
55
38
|
};
|
|
56
39
|
|
|
57
|
-
|
|
58
40
|
/** Load Source Graph and Links */
|
|
59
41
|
|
|
60
42
|
import { SourceRepository } from '@proteinjs/reflection';
|
|
61
43
|
SourceRepository.merge(sourceGraph, sourceLinks);
|
|
62
44
|
|
|
63
|
-
|
|
64
|
-
export * from '../index';
|
|
45
|
+
export * from '../index';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A server impl",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,39 +21,23 @@
|
|
|
21
21
|
"watch": "reflection-watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
|
|
25
24
|
"@proteinjs/event": "^1.0.8",
|
|
26
25
|
"@proteinjs/logger": "1.0.12",
|
|
27
26
|
"@proteinjs/reflection": "1.1.10",
|
|
28
|
-
"@proteinjs/server-api": "^
|
|
27
|
+
"@proteinjs/server-api": "^3.0.0",
|
|
29
28
|
"@proteinjs/util-node": "1.6.0",
|
|
30
29
|
"body-parser": "1.19.0",
|
|
31
|
-
"buffer": "6.0.3",
|
|
32
30
|
"cookie-parser": "1.4.5",
|
|
33
|
-
"crypto-browserify": "3.12.0",
|
|
34
|
-
"css-loader": "7.1.2",
|
|
35
31
|
"events": "3.3.0",
|
|
36
32
|
"express": "4.17.1",
|
|
37
33
|
"express-session": "1.17.1",
|
|
38
|
-
"file-loader": "6.2.0",
|
|
39
34
|
"passport": "0.4.1",
|
|
40
35
|
"passport-local": "1.0.0",
|
|
41
|
-
"path-browserify": "1.0.1",
|
|
42
36
|
"process": "0.11.10",
|
|
43
37
|
"react": "18.2.0",
|
|
44
38
|
"react-helmet": "6.1.0",
|
|
45
|
-
"react-refresh": "0.14.0",
|
|
46
|
-
"react-refresh-typescript": "2.0.9",
|
|
47
39
|
"socket.io": "4.7.5",
|
|
48
|
-
"
|
|
49
|
-
"style-loader": "4.0.0",
|
|
50
|
-
"ts-loader": "8.0.3",
|
|
51
|
-
"typescript": "5.2.2",
|
|
52
|
-
"url": "0.11.3",
|
|
53
|
-
"util": "0.12.5",
|
|
54
|
-
"webpack": "5.88.2",
|
|
55
|
-
"webpack-dev-middleware": "7.0.0",
|
|
56
|
-
"webpack-hot-middleware": "2.26.0"
|
|
40
|
+
"typescript": "5.2.2"
|
|
57
41
|
},
|
|
58
42
|
"devDependencies": {
|
|
59
43
|
"@proteinjs/reflection-build": "1.4.1",
|
|
@@ -68,16 +52,13 @@
|
|
|
68
52
|
"@types/react-helmet": "6.1.0",
|
|
69
53
|
"@types/react-router": "5.1.20",
|
|
70
54
|
"@types/react-router-dom": "5.3.3",
|
|
71
|
-
"@types/webpack-hot-middleware": "2.25.9",
|
|
72
55
|
"@typescript-eslint/eslint-plugin": "7.8.0",
|
|
73
56
|
"@typescript-eslint/parser": "7.8.0",
|
|
74
57
|
"eslint": "8.57.0",
|
|
75
58
|
"eslint-config-prettier": "9.1.0",
|
|
76
|
-
"eslint-plugin-prettier": "5.1.3"
|
|
77
|
-
"react-dom": "18.2.0",
|
|
78
|
-
"react-router": "6.16.0",
|
|
79
|
-
"react-router-dom": "6.16.0"
|
|
59
|
+
"eslint-plugin-prettier": "5.1.3"
|
|
80
60
|
},
|
|
81
61
|
"main": "./dist/generated/index.js",
|
|
82
|
-
"types": "./dist/generated/index.d.ts"
|
|
62
|
+
"types": "./dist/generated/index.d.ts",
|
|
63
|
+
"gitHead": "31a0a96fc165669222300501d590c0a61bf5355f"
|
|
83
64
|
}
|
package/src/startServer.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { createRequire } from 'module';
|
|
1
3
|
import express from 'express';
|
|
2
4
|
import expressSession from 'express-session';
|
|
3
5
|
import cookieParser from 'cookie-parser';
|
|
4
6
|
import bodyParser from 'body-parser';
|
|
5
7
|
import passport from 'passport';
|
|
6
8
|
import passportLocal from 'passport-local';
|
|
7
|
-
import webpack from 'webpack';
|
|
8
|
-
import webpackDevMiddleware from 'webpack-dev-middleware';
|
|
9
|
-
import webpackHotMiddleware from 'webpack-hot-middleware';
|
|
10
9
|
import { Server as HttpServer } from 'http';
|
|
11
10
|
import {
|
|
12
11
|
Global,
|
|
@@ -19,7 +18,6 @@ import {
|
|
|
19
18
|
} from '@proteinjs/server-api';
|
|
20
19
|
import { loadRoutes, loadDefaultStarRoute } from './loadRoutes';
|
|
21
20
|
import { Logger } from '@proteinjs/logger';
|
|
22
|
-
import { setNodeModulesPath } from './nodeModulesPath';
|
|
23
21
|
import { SocketIOServerRepo, ExtendedSocket } from './SocketIOServerRepo';
|
|
24
22
|
|
|
25
23
|
const staticContentPath = '/static/';
|
|
@@ -103,33 +101,71 @@ function configureRequests(app: express.Express) {
|
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
function initializeHotReloading(app: express.Express, config: ServerConfig) {
|
|
104
|
+
// Enable only in dev with all required settings present
|
|
106
105
|
if (
|
|
107
106
|
!process.env.DEVELOPMENT ||
|
|
108
107
|
process.env.DISABLE_HOT_CLIENT_BUILDS ||
|
|
109
108
|
!config.hotClientBuilds ||
|
|
109
|
+
!config.hotClientBuilds.nodeModulesPath ||
|
|
110
|
+
!config.hotClientBuilds.webpackConfigPath ||
|
|
110
111
|
!config.staticContent?.staticContentDir ||
|
|
111
112
|
!config.staticContent?.appEntryPath
|
|
112
113
|
) {
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
117
|
+
const appRequire = makeAppRequire(config.hotClientBuilds.nodeModulesPath);
|
|
118
|
+
|
|
119
|
+
// Load webpack & middlewares from the consumer app
|
|
120
|
+
const webpack = appRequire('webpack');
|
|
121
|
+
const webpackDevMiddleware = appRequire('webpack-dev-middleware');
|
|
122
|
+
const webpackHotMiddleware = appRequire('webpack-hot-middleware');
|
|
123
|
+
|
|
124
|
+
const devConfig = createWebpackConfigOverlay(config, webpack);
|
|
125
|
+
|
|
126
|
+
const compiler = webpack(devConfig);
|
|
127
|
+
|
|
121
128
|
app.use(
|
|
122
|
-
webpackDevMiddleware(
|
|
129
|
+
webpackDevMiddleware(compiler, {
|
|
123
130
|
publicPath: staticContentPath,
|
|
124
131
|
})
|
|
125
132
|
);
|
|
126
|
-
app.use(webpackHotMiddleware(
|
|
133
|
+
app.use(webpackHotMiddleware(compiler));
|
|
127
134
|
}
|
|
128
135
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return
|
|
136
|
+
// Resolve modules (webpack + middlewares) from the consumer’s node_modules
|
|
137
|
+
function makeAppRequire(nodeModulesPath: string) {
|
|
138
|
+
// Any file under the consumer's node_modules works as a base for createRequire
|
|
139
|
+
return createRequire(path.join(nodeModulesPath, '__app_require__.js'));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function createWebpackConfigOverlay(config: ServerConfig, webpack: any) {
|
|
143
|
+
// Load the consumer webpack config (CommonJS). If it exports a function, call with { mode: 'development' }.
|
|
144
|
+
const consumerExport = require(config.hotClientBuilds!.webpackConfigPath);
|
|
145
|
+
const baseConfig = typeof consumerExport === 'function' ? consumerExport({ mode: 'development' }) : consumerExport;
|
|
146
|
+
const devConfig: any = { ...baseConfig };
|
|
147
|
+
|
|
148
|
+
devConfig.mode = 'development';
|
|
149
|
+
|
|
150
|
+
// Inject HMR client + the consumer's entrypoint (absolute path already provided)
|
|
151
|
+
// Keep it minimal: no query params; defaults are fine.
|
|
152
|
+
devConfig.entry = { app: ['webpack-hot-middleware/client', config.staticContent!.appEntryPath] };
|
|
153
|
+
|
|
154
|
+
// Ensure bundles are served from memory at /static/, and set a concrete path for plugins that read it.
|
|
155
|
+
devConfig.output = {
|
|
156
|
+
...(baseConfig.output || {}),
|
|
157
|
+
publicPath: staticContentPath,
|
|
158
|
+
path: config.staticContent!.staticContentDir, // safe for plugins; dev-middleware serves from memory
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// Ensure HMR plugin exists (idempotent)
|
|
162
|
+
devConfig.plugins = devConfig.plugins ?? [];
|
|
163
|
+
const hasHmr = devConfig.plugins.some((p: any) => p?.constructor?.name === 'HotModuleReplacementPlugin');
|
|
164
|
+
if (!hasHmr) {
|
|
165
|
+
devConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return devConfig;
|
|
133
169
|
}
|
|
134
170
|
|
|
135
171
|
function configureHttps(app: express.Express) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodeModulesPath.d.ts","sourceRoot":"","sources":["../../src/nodeModulesPath.ts"],"names":[],"mappings":"AAAA,eAAO,IAAI,eAAe,EAAE,MAAM,CAAC;AAEnC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,QAE9C"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setNodeModulesPath = exports.nodeModulesPath = void 0;
|
|
4
|
-
function setNodeModulesPath(path) {
|
|
5
|
-
exports.nodeModulesPath = path;
|
|
6
|
-
}
|
|
7
|
-
exports.setNodeModulesPath = setNodeModulesPath;
|
|
8
|
-
//# sourceMappingURL=nodeModulesPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodeModulesPath.js","sourceRoot":"","sources":["../../src/nodeModulesPath.ts"],"names":[],"mappings":";;;AAEA,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,uBAAe,GAAG,IAAI,CAAC;AACzB,CAAC;AAFD,gDAEC"}
|
package/dist/webpack.config.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import webpack = require("webpack");
|
|
2
|
-
import ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
|
|
3
|
-
export let mode: string;
|
|
4
|
-
export let devtool: string;
|
|
5
|
-
export namespace output {
|
|
6
|
-
let filename: string;
|
|
7
|
-
let library: string;
|
|
8
|
-
}
|
|
9
|
-
export namespace resolve {
|
|
10
|
-
let extensions: string[];
|
|
11
|
-
let alias: {
|
|
12
|
-
react: string;
|
|
13
|
-
process: string;
|
|
14
|
-
'@mui/joy': string;
|
|
15
|
-
'@mui/material': string;
|
|
16
|
-
'@mui/icons-material': string;
|
|
17
|
-
'webpack-hot-middleware': string;
|
|
18
|
-
'react-query': string;
|
|
19
|
-
'react-router': string;
|
|
20
|
-
'react-router-dom': string;
|
|
21
|
-
};
|
|
22
|
-
let fallback: {
|
|
23
|
-
crypto: string;
|
|
24
|
-
util: string;
|
|
25
|
-
events: string;
|
|
26
|
-
url: string;
|
|
27
|
-
buffer: string;
|
|
28
|
-
stream: string;
|
|
29
|
-
'process/browser': string;
|
|
30
|
-
path: string;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export namespace resolveLoader {
|
|
34
|
-
let modules: string[];
|
|
35
|
-
}
|
|
36
|
-
export namespace module {
|
|
37
|
-
let rules: ({
|
|
38
|
-
test: RegExp;
|
|
39
|
-
resolve: {
|
|
40
|
-
fullySpecified: boolean;
|
|
41
|
-
};
|
|
42
|
-
} | {
|
|
43
|
-
test: RegExp;
|
|
44
|
-
exclude: RegExp;
|
|
45
|
-
use: {
|
|
46
|
-
loader: string;
|
|
47
|
-
options: {
|
|
48
|
-
getCustomTransformers: () => {
|
|
49
|
-
before: any[];
|
|
50
|
-
};
|
|
51
|
-
transpileOnly: boolean;
|
|
52
|
-
};
|
|
53
|
-
}[];
|
|
54
|
-
} | {
|
|
55
|
-
test: RegExp;
|
|
56
|
-
use: {
|
|
57
|
-
loader: string;
|
|
58
|
-
options: {
|
|
59
|
-
name: string;
|
|
60
|
-
};
|
|
61
|
-
}[];
|
|
62
|
-
exclude?: undefined;
|
|
63
|
-
} | {
|
|
64
|
-
test: RegExp;
|
|
65
|
-
use: string[];
|
|
66
|
-
exclude?: undefined;
|
|
67
|
-
})[];
|
|
68
|
-
}
|
|
69
|
-
export namespace optimization {
|
|
70
|
-
namespace splitChunks {
|
|
71
|
-
namespace cacheGroups {
|
|
72
|
-
namespace vendor {
|
|
73
|
-
let test: RegExp;
|
|
74
|
-
let name: string;
|
|
75
|
-
let chunks: string;
|
|
76
|
-
let priority: number;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
export let plugins: (webpack.ProvidePlugin | webpack.HotModuleReplacementPlugin | ReactRefreshWebpackPlugin | webpack.NormalModuleReplacementPlugin)[];
|
|
82
|
-
//# sourceMappingURL=webpack.config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.config.d.ts","sourceRoot":"","sources":["../webpack.config.js"],"names":[],"mappings":""}
|
package/dist/webpack.config.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var path = require('path');
|
|
3
|
-
var webpack = require('webpack');
|
|
4
|
-
var ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
5
|
-
var ReactRefreshTypeScript = require('react-refresh-typescript');
|
|
6
|
-
var nodeModulesPath = require('./src/nodeModulesPath').nodeModulesPath;
|
|
7
|
-
// const nodeModulesPath = path.join(__dirname, '../../../');
|
|
8
|
-
// if there are module resolution issues, verify assumptions about pathing
|
|
9
|
-
// console.log(`nodeModulesPath: ${nodeModulesPath}`);
|
|
10
|
-
// see https://github.com/webpack/webpack/issues/11467#issuecomment-808618999/
|
|
11
|
-
// for details
|
|
12
|
-
var webpack5esmInteropRule = {
|
|
13
|
-
test: /\.m?js/,
|
|
14
|
-
resolve: {
|
|
15
|
-
fullySpecified: false,
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
module.exports = {
|
|
19
|
-
mode: 'development',
|
|
20
|
-
devtool: 'inline-source-map',
|
|
21
|
-
// entry provided dynamically in startServer.initializeHotReloading
|
|
22
|
-
// entry: {
|
|
23
|
-
// app: ['webpack-hot-middleware/client', './generated/index.ts'],
|
|
24
|
-
// },
|
|
25
|
-
output: {
|
|
26
|
-
filename: '[name].js',
|
|
27
|
-
// path and publicPath provided in startServer.initializeHotReloading
|
|
28
|
-
// path: path.join(__dirname, 'dist'),
|
|
29
|
-
library: '[name]',
|
|
30
|
-
},
|
|
31
|
-
resolve: {
|
|
32
|
-
extensions: ['.tsx', '.ts', '.js', '.json'],
|
|
33
|
-
alias: {
|
|
34
|
-
react: path.join(nodeModulesPath, 'react'),
|
|
35
|
-
process: 'process/browser',
|
|
36
|
-
'@mui/joy': path.join(nodeModulesPath, '@mui/joy'),
|
|
37
|
-
'@mui/material': path.join(nodeModulesPath, '@mui/material'),
|
|
38
|
-
'@mui/icons-material': path.join(nodeModulesPath, '@mui/icons-material'),
|
|
39
|
-
'webpack-hot-middleware': path.join(nodeModulesPath, 'webpack-hot-middleware'),
|
|
40
|
-
'react-query': path.join(nodeModulesPath, 'react-query'),
|
|
41
|
-
'react-router': path.join(nodeModulesPath, 'react-router'),
|
|
42
|
-
'react-router-dom': path.join(nodeModulesPath, 'react-router-dom'),
|
|
43
|
-
},
|
|
44
|
-
// provide shims for node libraries for webpack >= 5
|
|
45
|
-
fallback: {
|
|
46
|
-
crypto: require.resolve('crypto-browserify'),
|
|
47
|
-
util: require.resolve('util/'),
|
|
48
|
-
events: require.resolve('events/'),
|
|
49
|
-
url: require.resolve('url/'),
|
|
50
|
-
buffer: require.resolve('buffer/'),
|
|
51
|
-
stream: require.resolve('stream-browserify'),
|
|
52
|
-
'process/browser': require.resolve('process/browser'),
|
|
53
|
-
path: require.resolve('path-browserify'),
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
// since this webpack.config is invoked via webpack-dev-middleware in the process of the consuming server package (not this package)
|
|
57
|
-
// we need to let webpack know where to look for loaders like: file-loader and ts-loader
|
|
58
|
-
// it's ideal to keep those dependencies within this package instead of requiring them installed by the consumer
|
|
59
|
-
resolveLoader: {
|
|
60
|
-
modules: [nodeModulesPath, 'node_modules'],
|
|
61
|
-
},
|
|
62
|
-
module: {
|
|
63
|
-
rules: [
|
|
64
|
-
webpack5esmInteropRule,
|
|
65
|
-
// all files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'
|
|
66
|
-
// this will only transpile (to integrate with babel via ReactRefreshTypeScript); rely on the ide for compiler checks
|
|
67
|
-
{
|
|
68
|
-
test: /\.[jt]sx?$/,
|
|
69
|
-
exclude: /node_modules/,
|
|
70
|
-
use: [
|
|
71
|
-
{
|
|
72
|
-
loader: require.resolve('ts-loader'),
|
|
73
|
-
options: {
|
|
74
|
-
getCustomTransformers: function () { return ({
|
|
75
|
-
before: [ReactRefreshTypeScript()],
|
|
76
|
-
}); },
|
|
77
|
-
transpileOnly: true,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
// image files
|
|
83
|
-
{
|
|
84
|
-
test: /\.(png|jpe?g|gif|svg)$/i,
|
|
85
|
-
use: [
|
|
86
|
-
{
|
|
87
|
-
loader: 'file-loader',
|
|
88
|
-
options: {
|
|
89
|
-
name: '[path][name].[ext]', // This line will keep the original path and filename
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
test: /\.css$/i,
|
|
96
|
-
use: ['style-loader', 'css-loader'],
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
optimization: {
|
|
101
|
-
splitChunks: {
|
|
102
|
-
cacheGroups: {
|
|
103
|
-
vendor: {
|
|
104
|
-
test: /[\\/]node_modules[\\/]/,
|
|
105
|
-
name: 'vendor',
|
|
106
|
-
chunks: 'all',
|
|
107
|
-
priority: -10,
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
plugins: [
|
|
113
|
-
new webpack.ProvidePlugin({
|
|
114
|
-
process: 'process/browser',
|
|
115
|
-
Buffer: ['buffer', 'Buffer'],
|
|
116
|
-
}),
|
|
117
|
-
new webpack.HotModuleReplacementPlugin(),
|
|
118
|
-
new ReactRefreshWebpackPlugin(),
|
|
119
|
-
new webpack.NormalModuleReplacementPlugin(/^node:process$/, function (resource) {
|
|
120
|
-
resource.request = 'process/browser';
|
|
121
|
-
}),
|
|
122
|
-
new webpack.NormalModuleReplacementPlugin(/^node:path$/, function (resource) {
|
|
123
|
-
resource.request = 'path';
|
|
124
|
-
}),
|
|
125
|
-
new webpack.NormalModuleReplacementPlugin(/^node:url$/, function (resource) {
|
|
126
|
-
resource.request = 'url';
|
|
127
|
-
}),
|
|
128
|
-
],
|
|
129
|
-
};
|
|
130
|
-
//# sourceMappingURL=webpack.config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.config.js","sourceRoot":"","sources":["../webpack.config.js"],"names":[],"mappings":";AAAA,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,IAAI,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACjC,IAAM,yBAAyB,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AAClF,IAAM,sBAAsB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC3D,IAAA,eAAe,GAAK,OAAO,CAAC,uBAAuB,CAAC,gBAArC,CAAsC;AAE7D,6DAA6D;AAC7D,0EAA0E;AAC1E,sDAAsD;AAEtD,+EAA+E;AAC/E,cAAc;AACd,IAAM,sBAAsB,GAAG;IAC7B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP,cAAc,EAAE,KAA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B,OAAO,EAAE,iBAAiB;YAC1B,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;SAC7B,CAAC;QACF,IAAI,OAAO,CAAC,0BAA0B,EAAE;QACxC,IAAI,yBAAyB,EAAE;QAC/B,IAAI,OAAO,CAAC,6BAA6B,CAAC,gBAAgB,EAAE,UAAC,QAAQ;YACnE,QAAQ,CAAC,OAAO,GAAG,iBAAiB,CAAC;QACvC,CAAC,CAAC;QACF,IAAI,OAAO,CAAC,6BAA6B,CAAC,aAAa,EAAE,UAAC,QAAQ;YAChE,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;QAC5B,CAAC,CAAC;QACF,IAAI,OAAO,CAAC,6BAA6B,CAAC,YAAY,EAAE,UAAC,QAAQ;YAC/D,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;QAC3B,CAAC,CAAC;KACH;CACF,CAAC"}
|
package/src/nodeModulesPath.ts
DELETED
package/webpack.config.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var webpack = require('webpack');
|
|
3
|
-
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
4
|
-
const ReactRefreshTypeScript = require('react-refresh-typescript');
|
|
5
|
-
const { nodeModulesPath } = require('./src/nodeModulesPath');
|
|
6
|
-
|
|
7
|
-
// const nodeModulesPath = path.join(__dirname, '../../../');
|
|
8
|
-
// if there are module resolution issues, verify assumptions about pathing
|
|
9
|
-
// console.log(`nodeModulesPath: ${nodeModulesPath}`);
|
|
10
|
-
|
|
11
|
-
// see https://github.com/webpack/webpack/issues/11467#issuecomment-808618999/
|
|
12
|
-
// for details
|
|
13
|
-
const webpack5esmInteropRule = {
|
|
14
|
-
test: /\.m?js/,
|
|
15
|
-
resolve: {
|
|
16
|
-
fullySpecified: false,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
module.exports = {
|
|
21
|
-
mode: 'development',
|
|
22
|
-
devtool: 'inline-source-map',
|
|
23
|
-
// entry provided dynamically in startServer.initializeHotReloading
|
|
24
|
-
// entry: {
|
|
25
|
-
// app: ['webpack-hot-middleware/client', './generated/index.ts'],
|
|
26
|
-
// },
|
|
27
|
-
output: {
|
|
28
|
-
filename: '[name].js',
|
|
29
|
-
// path and publicPath provided in startServer.initializeHotReloading
|
|
30
|
-
// path: path.join(__dirname, 'dist'),
|
|
31
|
-
library: '[name]',
|
|
32
|
-
},
|
|
33
|
-
resolve: {
|
|
34
|
-
extensions: ['.tsx', '.ts', '.js', '.json'],
|
|
35
|
-
alias: {
|
|
36
|
-
react: path.join(nodeModulesPath, 'react'),
|
|
37
|
-
process: 'process/browser',
|
|
38
|
-
'@mui/joy': path.join(nodeModulesPath, '@mui/joy'),
|
|
39
|
-
'@mui/material': path.join(nodeModulesPath, '@mui/material'),
|
|
40
|
-
'@mui/icons-material': path.join(nodeModulesPath, '@mui/icons-material'),
|
|
41
|
-
'webpack-hot-middleware': path.join(nodeModulesPath, 'webpack-hot-middleware'),
|
|
42
|
-
'react-query': path.join(nodeModulesPath, 'react-query'),
|
|
43
|
-
'react-router': path.join(nodeModulesPath, 'react-router'),
|
|
44
|
-
'react-router-dom': path.join(nodeModulesPath, 'react-router-dom'),
|
|
45
|
-
},
|
|
46
|
-
// provide shims for node libraries for webpack >= 5
|
|
47
|
-
fallback: {
|
|
48
|
-
crypto: require.resolve('crypto-browserify'),
|
|
49
|
-
util: require.resolve('util/'),
|
|
50
|
-
events: require.resolve('events/'),
|
|
51
|
-
url: require.resolve('url/'),
|
|
52
|
-
buffer: require.resolve('buffer/'),
|
|
53
|
-
stream: require.resolve('stream-browserify'),
|
|
54
|
-
'process/browser': require.resolve('process/browser'),
|
|
55
|
-
path: require.resolve('path-browserify'),
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
// since this webpack.config is invoked via webpack-dev-middleware in the process of the consuming server package (not this package)
|
|
59
|
-
// we need to let webpack know where to look for loaders like: file-loader and ts-loader
|
|
60
|
-
// it's ideal to keep those dependencies within this package instead of requiring them installed by the consumer
|
|
61
|
-
resolveLoader: {
|
|
62
|
-
modules: [nodeModulesPath, 'node_modules'],
|
|
63
|
-
},
|
|
64
|
-
module: {
|
|
65
|
-
rules: [
|
|
66
|
-
webpack5esmInteropRule,
|
|
67
|
-
// all files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'
|
|
68
|
-
// this will only transpile (to integrate with babel via ReactRefreshTypeScript); rely on the ide for compiler checks
|
|
69
|
-
{
|
|
70
|
-
test: /\.[jt]sx?$/,
|
|
71
|
-
exclude: /node_modules/,
|
|
72
|
-
use: [
|
|
73
|
-
{
|
|
74
|
-
loader: require.resolve('ts-loader'),
|
|
75
|
-
options: {
|
|
76
|
-
getCustomTransformers: () => ({
|
|
77
|
-
before: [ReactRefreshTypeScript()],
|
|
78
|
-
}),
|
|
79
|
-
transpileOnly: true,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
// image files
|
|
85
|
-
{
|
|
86
|
-
test: /\.(png|jpe?g|gif|svg)$/i,
|
|
87
|
-
use: [
|
|
88
|
-
{
|
|
89
|
-
loader: 'file-loader',
|
|
90
|
-
options: {
|
|
91
|
-
name: '[path][name].[ext]', // This line will keep the original path and filename
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
test: /\.css$/i,
|
|
98
|
-
use: ['style-loader', 'css-loader'],
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
optimization: {
|
|
103
|
-
splitChunks: {
|
|
104
|
-
cacheGroups: {
|
|
105
|
-
vendor: {
|
|
106
|
-
test: /[\\/]node_modules[\\/]/, // Matches node_modules folder
|
|
107
|
-
name: 'vendor',
|
|
108
|
-
chunks: 'all',
|
|
109
|
-
priority: -10,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
plugins: [
|
|
115
|
-
new webpack.ProvidePlugin({
|
|
116
|
-
process: 'process/browser',
|
|
117
|
-
Buffer: ['buffer', 'Buffer'],
|
|
118
|
-
}),
|
|
119
|
-
new webpack.HotModuleReplacementPlugin(),
|
|
120
|
-
new ReactRefreshWebpackPlugin(),
|
|
121
|
-
new webpack.NormalModuleReplacementPlugin(/^node:process$/, (resource) => {
|
|
122
|
-
resource.request = 'process/browser';
|
|
123
|
-
}),
|
|
124
|
-
new webpack.NormalModuleReplacementPlugin(/^node:path$/, (resource) => {
|
|
125
|
-
resource.request = 'path';
|
|
126
|
-
}),
|
|
127
|
-
new webpack.NormalModuleReplacementPlugin(/^node:url$/, (resource) => {
|
|
128
|
-
resource.request = 'url';
|
|
129
|
-
}),
|
|
130
|
-
],
|
|
131
|
-
};
|