@rnw-community/nestjs-webpack-swc 0.27.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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2021 Vitalii Yehorov and others
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.
@@ -0,0 +1,4 @@
1
+ import type { Configuration } from 'webpack';
2
+ import type Webpack from 'webpack';
3
+ export declare const getNestJSWebpackDevConfig: (options: Configuration, webpack: typeof Webpack) => Configuration;
4
+ //# sourceMappingURL=get-nestjs-webpack-dev.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-nestjs-webpack-dev.config.d.ts","sourceRoot":"","sources":["../../src/config/get-nestjs-webpack-dev.config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAyB,MAAM,SAAS,CAAC;AACpE,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,eAAO,MAAM,yBAAyB,YAAa,aAAa,WAAW,cAAc,KAAG,aAU1F,CAAC"}
@@ -0,0 +1,37 @@
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
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.getNestJSWebpackDevConfig = void 0;
24
+ var run_script_webpack_plugin_1 = require("run-script-webpack-plugin");
25
+ var get_nestjs_webpack_generic_config_1 = require("./get-nestjs-webpack-generic.config");
26
+ var getNestJSWebpackDevConfig = function (options, webpack) {
27
+ var _a;
28
+ return (__assign(__assign({}, (0, get_nestjs_webpack_generic_config_1.getNestJSWebpackGenericConfig)(options)), {
29
+ // @ts-expect-error Improve this extending
30
+ entry: ['webpack/hot/poll?100', options.entry], plugins: __spreadArray(__spreadArray([], options.plugins, true), [
31
+ new webpack.HotModuleReplacementPlugin(),
32
+ new webpack.WatchIgnorePlugin({ paths: [/\.js$/u, /\.d\.ts$/u] }),
33
+ new run_script_webpack_plugin_1.RunScriptWebpackPlugin({ name: (_a = options.output) === null || _a === void 0 ? void 0 : _a.filename, autoRestart: false }),
34
+ ], false) }));
35
+ };
36
+ exports.getNestJSWebpackDevConfig = getNestJSWebpackDevConfig;
37
+ //# sourceMappingURL=get-nestjs-webpack-dev.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-nestjs-webpack-dev.config.js","sourceRoot":"","sources":["../../src/config/get-nestjs-webpack-dev.config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,uEAAmE;AAEnE,yFAAoF;AAK7E,IAAM,yBAAyB,GAAG,UAAC,OAAsB,EAAE,OAAuB;;IAAoB,OAAA,uBACtG,IAAA,iEAA6B,EAAC,OAAO,CAAC;QACzC,0CAA0C;QAC1C,KAAK,EAAE,CAAC,sBAAsB,EAAE,OAAO,CAAC,KAAK,CAAC,EAC9C,OAAO,kCACC,OAAO,CAAC,OAAmC;YAC/C,IAAI,OAAO,CAAC,0BAA0B,EAAE;YACxC,IAAI,OAAO,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,CAAC;YACjE,IAAI,kDAAsB,CAAC,EAAE,IAAI,EAAE,MAAA,OAAO,CAAC,MAAM,0CAAE,QAAkB,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;qBAElG,CAAA;CAAA,CAAC;AAVU,QAAA,yBAAyB,6BAUnC"}
@@ -0,0 +1,3 @@
1
+ import type { Configuration } from 'webpack';
2
+ export declare const getNestJSWebpackGenericConfig: (options: Configuration, swcOptions?: Record<string, unknown>) => Configuration;
3
+ //# sourceMappingURL=get-nestjs-webpack-generic.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-nestjs-webpack-generic.config.d.ts","sourceRoot":"","sources":["../../src/config/get-nestjs-webpack-generic.config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,6BAA6B,YAC7B,aAAa,eACV,OAAO,MAAM,EAAE,OAAO,CAAC,KACpC,aAkBD,CAAC"}
@@ -0,0 +1,38 @@
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
+ };
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.getNestJSWebpackGenericConfig = void 0;
18
+ var path_1 = __importDefault(require("path"));
19
+ var webpack_node_externals_1 = __importDefault(require("webpack-node-externals"));
20
+ var swc_config_1 = require("./swc.config");
21
+ var getNestJSWebpackGenericConfig = function (options, swcOptions) {
22
+ if (swcOptions === void 0) { swcOptions = {}; }
23
+ return (__assign(__assign({}, options), { externals: [(0, webpack_node_externals_1.default)({ modulesFromFile: true, allowlist: ['webpack/hot/poll?100'] })], externalsPresets: { node: true }, cache: {
24
+ type: 'filesystem',
25
+ cacheDirectory: path_1.default.resolve(process.cwd(), '.build_cache'),
26
+ allowCollectingMemory: true,
27
+ }, module: {
28
+ rules: [
29
+ {
30
+ test: /\.tsx?$/u,
31
+ use: { loader: 'swc-loader', options: __assign(__assign({}, swc_config_1.swcConfig), swcOptions) },
32
+ exclude: /(node_modules)/u,
33
+ },
34
+ ],
35
+ } }));
36
+ };
37
+ exports.getNestJSWebpackGenericConfig = getNestJSWebpackGenericConfig;
38
+ //# sourceMappingURL=get-nestjs-webpack-generic.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-nestjs-webpack-generic.config.js","sourceRoot":"","sources":["../../src/config/get-nestjs-webpack-generic.config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAAwB;AAExB,kFAAmD;AAEnD,2CAAyC;AAIlC,IAAM,6BAA6B,GAAG,UACzC,OAAsB,EACtB,UAAwC;IAAxC,2BAAA,EAAA,eAAwC;IACxB,OAAA,uBACb,OAAO,KACV,SAAS,EAAE,CAAC,IAAA,gCAAa,EAAC,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,EAC1F,gBAAgB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAChC,KAAK,EAAE;YACH,IAAI,EAAE,YAAY;YAClB,cAAc,EAAE,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;YAC3D,qBAAqB,EAAE,IAAI;SAC9B,EACD,MAAM,EAAE;YACJ,KAAK,EAAE;gBACH;oBACI,IAAI,EAAE,UAAU;oBAChB,GAAG,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,wBAAO,sBAAS,GAAK,UAAU,CAAE,EAAE;oBACvE,OAAO,EAAE,iBAAiB;iBAC7B;aACJ;SACJ,IACH;AAlBkB,CAkBlB,CAAC;AArBU,QAAA,6BAA6B,iCAqBvC"}
@@ -0,0 +1,4 @@
1
+ import type { Configuration } from 'webpack';
2
+ import type Webpack from 'webpack';
3
+ export declare const getNestJSWebpackProdConfig: (options: Configuration, _webpack: typeof Webpack) => Configuration;
4
+ //# sourceMappingURL=get-nestjs-webpack-prod.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-nestjs-webpack-prod.config.d.ts","sourceRoot":"","sources":["../../src/config/get-nestjs-webpack-prod.config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,eAAO,MAAM,0BAA0B,YAAa,aAAa,YAAY,cAAc,KAAG,aAE5F,CAAC"}
@@ -0,0 +1,18 @@
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
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getNestJSWebpackProdConfig = void 0;
15
+ var get_nestjs_webpack_generic_config_1 = require("./get-nestjs-webpack-generic.config");
16
+ var getNestJSWebpackProdConfig = function (options, _webpack) { return (__assign({}, (0, get_nestjs_webpack_generic_config_1.getNestJSWebpackGenericConfig)(options, { minify: true }))); };
17
+ exports.getNestJSWebpackProdConfig = getNestJSWebpackProdConfig;
18
+ //# sourceMappingURL=get-nestjs-webpack-prod.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-nestjs-webpack-prod.config.js","sourceRoot":"","sources":["../../src/config/get-nestjs-webpack-prod.config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,yFAAoF;AAK7E,IAAM,0BAA0B,GAAG,UAAC,OAAsB,EAAE,QAAwB,IAAoB,OAAA,cACxG,IAAA,iEAA6B,EAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAC7D,EAF6G,CAE7G,CAAC;AAFU,QAAA,0BAA0B,8BAEpC"}
@@ -0,0 +1,20 @@
1
+ export declare const swcConfig: {
2
+ sourceMaps: boolean;
3
+ module: {
4
+ type: string;
5
+ strict: boolean;
6
+ };
7
+ jsc: {
8
+ target: string;
9
+ parser: {
10
+ syntax: string;
11
+ decorators: boolean;
12
+ };
13
+ transform: {
14
+ legacyDecorator: boolean;
15
+ decoratorMetadata: boolean;
16
+ };
17
+ keepClassNames: boolean;
18
+ };
19
+ };
20
+ //# sourceMappingURL=swc.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swc.config.d.ts","sourceRoot":"","sources":["../../src/config/swc.config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;CAkBrB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.swcConfig = void 0;
4
+ exports.swcConfig = {
5
+ sourceMaps: false,
6
+ module: {
7
+ type: 'commonjs',
8
+ strict: true,
9
+ },
10
+ jsc: {
11
+ target: 'es2020',
12
+ parser: {
13
+ syntax: 'typescript',
14
+ decorators: true,
15
+ },
16
+ transform: {
17
+ legacyDecorator: true,
18
+ decoratorMetadata: true,
19
+ },
20
+ keepClassNames: true,
21
+ },
22
+ };
23
+ //# sourceMappingURL=swc.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swc.config.js","sourceRoot":"","sources":["../../src/config/swc.config.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACrB,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,IAAI;KACf;IACD,GAAG,EAAE;QACD,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACJ,MAAM,EAAE,YAAY;YACpB,UAAU,EAAE,IAAI;SACnB;QACD,SAAS,EAAE;YACP,eAAe,EAAE,IAAI;YACrB,iBAAiB,EAAE,IAAI;SAC1B;QACD,cAAc,EAAE,IAAI;KACvB;CACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './config/get-nestjs-webpack-generic.config';
2
+ export * from './config/get-nestjs-webpack-dev.config';
3
+ export * from './config/get-nestjs-webpack-prod.config';
4
+ export * from './config/swc.config';
5
+ export * from './typeorm/import-typeorm-webpack-migrations.util';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qBAAqB,CAAC;AAEpC,cAAc,kDAAkD,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./config/get-nestjs-webpack-generic.config"), exports);
18
+ __exportStar(require("./config/get-nestjs-webpack-dev.config"), exports);
19
+ __exportStar(require("./config/get-nestjs-webpack-prod.config"), exports);
20
+ __exportStar(require("./config/swc.config"), exports);
21
+ __exportStar(require("./typeorm/import-typeorm-webpack-migrations.util"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6EAA2D;AAC3D,yEAAuD;AACvD,0EAAwD;AACxD,sDAAoC;AAEpC,mFAAiE"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="@types/webpack-env" />
2
+ export declare const importTypeormWebpackMigrations: (requireContext: __WebpackModuleApi.RequireContext) => Function[];
3
+ //# sourceMappingURL=import-typeorm-webpack-migrations.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-typeorm-webpack-migrations.util.d.ts","sourceRoot":"","sources":["../../src/typeorm/import-typeorm-webpack-migrations.util.ts"],"names":[],"mappings":";AACA,eAAO,MAAM,8BAA8B,mBAAoB,mBAAmB,cAAc,KAAG,QAAQ,EAS5F,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.importTypeormWebpackMigrations = void 0;
13
+ /* eslint-disable @typescript-eslint/ban-types */
14
+ var importTypeormWebpackMigrations = function (requireContext) {
15
+ return requireContext
16
+ .keys()
17
+ .sort()
18
+ .map(function (filename) {
19
+ return Object.entries(requireContext(filename))
20
+ .filter(function (_a) {
21
+ var exported = _a[1];
22
+ return typeof exported === 'function';
23
+ })
24
+ .reduce(function (result, _a) {
25
+ var exported = _a[1];
26
+ return __spreadArray(__spreadArray([], result, true), [exported], false);
27
+ }, []);
28
+ })
29
+ .flat();
30
+ };
31
+ exports.importTypeormWebpackMigrations = importTypeormWebpackMigrations;
32
+ //# sourceMappingURL=import-typeorm-webpack-migrations.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-typeorm-webpack-migrations.util.js","sourceRoot":"","sources":["../../src/typeorm/import-typeorm-webpack-migrations.util.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAAiD;AAC1C,IAAM,8BAA8B,GAAG,UAAC,cAAiD;IAC5F,OAAA,cAAc;SACT,IAAI,EAAE;SACN,IAAI,EAAE;SACN,GAAG,CAAC,UAAA,QAAQ;QACT,OAAA,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAA6B,CAAC;aAC/D,MAAM,CAAC,UAAC,EAAY;gBAAT,QAAQ,QAAA;YAAM,OAAA,OAAO,QAAQ,KAAK,UAAU;QAA9B,CAA8B,CAAC;aACxD,MAAM,CAAa,UAAC,MAAM,EAAE,EAAY;gBAAT,QAAQ,QAAA;YAAM,uCAAI,MAAM,UAAE,QAAQ;QAApB,CAAqB,EAAE,EAAE,CAAC;IAF5E,CAE4E,CAC/E;SACA,IAAI,EAAE;AARX,CAQW,CAAC;AATH,QAAA,8BAA8B,kCAS3B"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@rnw-community/nestjs-webpack-swc",
3
+ "version": "0.27.0",
4
+ "private": false,
5
+ "description": "NestJS typed config",
6
+ "keywords": [
7
+ "nestjs",
8
+ "nestjs webpack",
9
+ "nestjs swc",
10
+ "nestjs swc-loader"
11
+ ],
12
+ "repository": "https://github.com/rnw-community/rnw-community/tree/master/packages/nestjs-typed-config",
13
+ "license": "MIT",
14
+ "main": "dist/index.js",
15
+ "types": "dist/index.d.ts",
16
+ "files": [
17
+ "dist/**/*"
18
+ ],
19
+ "sideEffects": "false",
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "scripts": {
24
+ "ts": "tsc --pretty -p tsconfig.json",
25
+ "build": "tsc --pretty -p tsconfig.build.json",
26
+ "postbuild": "rm -rf ./dist/*.tsbuildinfo",
27
+ "lint": "yarn eslint src",
28
+ "lint:fix": "yarn lint --fix src",
29
+ "test": "yarn jest",
30
+ "test:coverage": "yarn jest --coverage",
31
+ "format": "prettier --write \"./src/**/*.{ts,tsx}\"",
32
+ "clear": "rm -rf coverage && rm -rf dist && rm -f *.tsbuildinfo",
33
+ "clear:deps": "rm -rf ./node_modules && rm -rf ./dist"
34
+ },
35
+ "engines": {
36
+ "node": ">=14.0.0"
37
+ },
38
+ "gitHead": "e6cc8ebd2e3f5ca4538ea368230e6f5e92ef3737",
39
+ "dependencies": {
40
+ "@rnw-community/shared": "^0.8.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/webpack-env": "^1.18.0",
44
+ "@types/webpack-node-externals": "^2.5.3",
45
+ "run-script-webpack-plugin": "^0.1.1",
46
+ "webpack": "^5.74.0",
47
+ "webpack-node-externals": "^3.0.0"
48
+ },
49
+ "peerDependencies": {
50
+ "@swc/cli": "^0.1.57",
51
+ "@swc/core": "^1.2.239",
52
+ "@swc/helpers": "^0.4.7",
53
+ "run-script-webpack-plugin": "^0.1.1",
54
+ "swc-loader": "^0.2.3",
55
+ "webpack": "^5.74.0",
56
+ "webpack-node-externals": "^3.0.0"
57
+ }
58
+ }
package/readme.md ADDED
@@ -0,0 +1,78 @@
1
+ # NestJS Webpack + SWC configuration
2
+
3
+ NestJS webpack and SWC configuration helpers, this can speed up your local NestJS development up to
4
+ 10x.
5
+
6
+ - [NestJS](https://docs.nestjs.com) offers [Webpack](https://webpack.js.org) configuration with [HMR](https://docs.nestjs.com/recipes/hot-reload) which significantly
7
+ improves rebuild speed within local development especially if your project grows.
8
+ - [SWC](https://swc.rs) is **next generation of fast developer tools** which complies typescript blazingly
9
+ fast compared to [Babel](https://babeljs.io), and it has webpack [swc-loader](https://github.com/swc-project/swc-loader)
10
+
11
+ > This package helps to easily configure NestJS webpack and SWC integration and make you DX good and quick again
12
+
13
+ ## Installation
14
+
15
+ 1. Install package `@rnw-community/nestjs-webpack-swc` using your package manager
16
+ 2. Install additional peer dependencies:
17
+ - [run-script-webpack-plugin](https://github.com/atassis/run-script-webpack-plugin)
18
+ - [webpack](https://github.com/webpack/webpack)
19
+ - [webpack-node-externals](https://github.com/liady/webpack-node-externals)
20
+ - [swc-loader](https://github.com/swc-project/swc-loader)
21
+ - [@swc/cli](https://github.com/swc-project/cli)
22
+ - [@swc/core](https://github.com/swc-project/swc)
23
+ - [@swc/helpers](https://github.com/swc-project/helpers)
24
+
25
+ ## Configuration
26
+
27
+ ### Development webpack configuration
28
+
29
+ Create `webpack-dev.config.js` in root of the NestJS package:
30
+
31
+ ```js
32
+ module.exports = require('@rnw-community/nestjs-webpack-swc').getNestJSWebpackDevConfig;
33
+ ```
34
+
35
+ ### Production webpack configuration
36
+
37
+ Create `webpack-prod.config.js` in root of the NestJS package:
38
+
39
+ ```js
40
+ module.exports = require('@dotgoclub/be-lib').getNestJSWebpackProdConfig;
41
+ ```
42
+
43
+ ### Scripts package.json
44
+
45
+ Change `package.json` `build`, `start:dev` scripts:
46
+
47
+ ```json
48
+ "build": "nest build --webpack --webpackPath webpack-prod.config.js",
49
+ "start:dev": "nest build --webpack --webpackPath webpack-dev.config.js --watch"
50
+ ```
51
+
52
+ ## Typeorm migrations
53
+
54
+ If your project is using [TypeORM](https://typeorm.io), then you will face problems with running migrations from NestJS app,
55
+ this package provides utility for loading TypeORM migrations within webpack build.
56
+
57
+ Install additional peer dependencies:
58
+
59
+ - [@types/webpack-env](https://www.npmjs.com/package/@types/webpack-env)
60
+
61
+ Following code will return class instances array that you can pass to TypeORM configuration, you will only need to provide
62
+ path to the folder where all migrations are stored:
63
+
64
+ ```ts
65
+ const migrations = importTypeormWebpackMigrations(require.context('./migration/', true, /\.ts$/u));
66
+ ```
67
+
68
+ ## SWC bindings
69
+
70
+ If your project is running inside the docker container and your host system has different architecture
71
+ you may end up with `Error: Bindings not found` SWC error, this is happening because when you install
72
+ [SWC](https://swc.rs) it uses the bindings for your host machine, to fix this you can add the following
73
+ `package.json` script and add it to `postinstall` script:
74
+
75
+ ```json
76
+ "swc-install-bindings": "npm install --no-save --loglevel=error --prefer-offline --no-audit --progress=false --force @swc/core-linux-arm64-musl @swc/core-linux-x64-musl",
77
+ "postinstall": "yarn swc-install-bindings"
78
+ ```