quidproquo-deploy-webpack 0.0.35 → 0.0.36
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/package.json +1 -4
- package/src/loaders/qpq-dynamic-loader.js +26 -0
- package/src/webpack.config.ts +95 -0
- package/tsconfig.json +8 -0
- package/lib/loaders/qpq-dynamic-loader.d.ts +0 -2
- package/lib/loaders/qpq-dynamic-loader.js +0 -21
- package/lib/webpack.config.d.ts +0 -41
- package/lib/webpack.config.js +0 -86
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-deploy-webpack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/webpack.config.js",
|
|
6
6
|
"types": "./lib/webpack.config.d.js",
|
|
7
|
-
"files": [
|
|
8
|
-
"lib/**/*"
|
|
9
|
-
],
|
|
10
7
|
"scripts": {
|
|
11
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
9
|
"clean": "npx rimraf lib",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = function (source) {
|
|
4
|
+
// console.log('Loader Running');
|
|
5
|
+
// console.log(process.env.QPQLoaderConfig);
|
|
6
|
+
// console.log('---');
|
|
7
|
+
|
|
8
|
+
const config = JSON.parse(process.env.QPQLoaderConfig);
|
|
9
|
+
const ifStatements = config.allSrcEntries.map((e) => {
|
|
10
|
+
return `if (moduleName === '${e}') {
|
|
11
|
+
return await require('./${e.replace(/\\/g, '/')}');
|
|
12
|
+
}`;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const ifBlock = ifStatements.join(' else ');
|
|
16
|
+
|
|
17
|
+
const result = `module.exports = async (moduleName) => {
|
|
18
|
+
${ifBlock};
|
|
19
|
+
|
|
20
|
+
return null;
|
|
21
|
+
}`;
|
|
22
|
+
|
|
23
|
+
// console.log(result);
|
|
24
|
+
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
import { qpqCoreUtils, QPQConfig } from 'quidproquo-core';
|
|
4
|
+
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
5
|
+
import webpack from 'webpack';
|
|
6
|
+
|
|
7
|
+
const getWebpackBuildMode = (qpqConfig: QPQConfig): string => {
|
|
8
|
+
const feature = qpqCoreUtils.getAppFeature(qpqConfig);
|
|
9
|
+
|
|
10
|
+
if (['development', 'production'].indexOf(feature) >= 0) {
|
|
11
|
+
return feature;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return 'production';
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getWebpackConfig = (qpqConfig: QPQConfig, buildPath: string, outputPrefix: string) => {
|
|
18
|
+
const allSrcEntries = [
|
|
19
|
+
...qpqCoreUtils.getAllSrcEntries(qpqConfig),
|
|
20
|
+
...qpqWebServerUtils.getAllSrcEntries(qpqConfig),
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
// set the qpq config env for loaders
|
|
24
|
+
process.env.QPQLoaderConfig = JSON.stringify({
|
|
25
|
+
allSrcEntries,
|
|
26
|
+
rootDir: path.resolve(buildPath, '..'),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
// entry: allSrcEntries.reduce(
|
|
31
|
+
// (entry, path) => ({
|
|
32
|
+
// ...entry,
|
|
33
|
+
// [`./${outputPrefix}/${path}`]: `./${path}`,
|
|
34
|
+
// }),
|
|
35
|
+
// {},
|
|
36
|
+
// ),
|
|
37
|
+
|
|
38
|
+
entry: {
|
|
39
|
+
lambdaAPIGatewayEvent: 'quidproquo-deploy-awscdk/src/lambdas/LambdaAPIGatewayEvent.ts',
|
|
40
|
+
lambdaEventBridgeEvent: 'quidproquo-deploy-awscdk/src/lambdas/lambdaEventBridgeEvent.ts',
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
resolveLoader: {
|
|
44
|
+
modules: [path.resolve(__dirname, 'loaders'), 'node_modules'],
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// mode: getWebpackBuildMode(qpqConfig),
|
|
48
|
+
mode: 'production',
|
|
49
|
+
|
|
50
|
+
// We should: sort out how to split the bundles and get it to work on aws
|
|
51
|
+
// optimization: {
|
|
52
|
+
// splitChunks: {
|
|
53
|
+
// // include all types of chunks
|
|
54
|
+
// chunks: "all",
|
|
55
|
+
// },
|
|
56
|
+
// },
|
|
57
|
+
|
|
58
|
+
target: 'node',
|
|
59
|
+
output: {
|
|
60
|
+
// Output path
|
|
61
|
+
path: buildPath,
|
|
62
|
+
filename: '[name].js',
|
|
63
|
+
|
|
64
|
+
// Allow compiling as a lib ~ don't tree shake my exports plz
|
|
65
|
+
globalObject: 'this',
|
|
66
|
+
libraryTarget: 'commonjs2',
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
resolve: {
|
|
70
|
+
extensions: ['.ts', '.tsx', '.js', '.json'],
|
|
71
|
+
fallback: {
|
|
72
|
+
crypto: false,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
module: {
|
|
77
|
+
rules: [
|
|
78
|
+
{
|
|
79
|
+
test: /\.(ts)$/,
|
|
80
|
+
loader: 'babel-loader',
|
|
81
|
+
options: {
|
|
82
|
+
// without additional settings, this will reference .babelrc
|
|
83
|
+
presets: ['@babel/preset-typescript'],
|
|
84
|
+
},
|
|
85
|
+
exclude: /node_modules/,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
test: /\.(yaml|json)$/,
|
|
89
|
+
type: 'asset/source',
|
|
90
|
+
exclude: /node_modules/,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const path = require('path');
|
|
3
|
-
module.exports = function (source) {
|
|
4
|
-
// console.log('Loader Running');
|
|
5
|
-
// console.log(process.env.QPQLoaderConfig);
|
|
6
|
-
// console.log('---');
|
|
7
|
-
const config = JSON.parse(process.env.QPQLoaderConfig);
|
|
8
|
-
const ifStatements = config.allSrcEntries.map((e) => {
|
|
9
|
-
return `if (moduleName === '${e}') {
|
|
10
|
-
return await require('./${e.replace(/\\/g, '/')}');
|
|
11
|
-
}`;
|
|
12
|
-
});
|
|
13
|
-
const ifBlock = ifStatements.join(' else ');
|
|
14
|
-
const result = `module.exports = async (moduleName) => {
|
|
15
|
-
${ifBlock};
|
|
16
|
-
|
|
17
|
-
return null;
|
|
18
|
-
}`;
|
|
19
|
-
// console.log(result);
|
|
20
|
-
return result;
|
|
21
|
-
};
|
package/lib/webpack.config.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
-
export declare const getWebpackConfig: (qpqConfig: QPQConfig, buildPath: string, outputPrefix: string) => {
|
|
3
|
-
entry: {
|
|
4
|
-
lambdaAPIGatewayEvent: string;
|
|
5
|
-
lambdaEventBridgeEvent: string;
|
|
6
|
-
};
|
|
7
|
-
resolveLoader: {
|
|
8
|
-
modules: string[];
|
|
9
|
-
};
|
|
10
|
-
mode: string;
|
|
11
|
-
target: string;
|
|
12
|
-
output: {
|
|
13
|
-
path: string;
|
|
14
|
-
filename: string;
|
|
15
|
-
globalObject: string;
|
|
16
|
-
libraryTarget: string;
|
|
17
|
-
};
|
|
18
|
-
resolve: {
|
|
19
|
-
extensions: string[];
|
|
20
|
-
fallback: {
|
|
21
|
-
crypto: boolean;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
module: {
|
|
25
|
-
rules: ({
|
|
26
|
-
test: RegExp;
|
|
27
|
-
loader: string;
|
|
28
|
-
options: {
|
|
29
|
-
presets: string[];
|
|
30
|
-
};
|
|
31
|
-
exclude: RegExp;
|
|
32
|
-
type?: undefined;
|
|
33
|
-
} | {
|
|
34
|
-
test: RegExp;
|
|
35
|
-
type: string;
|
|
36
|
-
exclude: RegExp;
|
|
37
|
-
loader?: undefined;
|
|
38
|
-
options?: undefined;
|
|
39
|
-
})[];
|
|
40
|
-
};
|
|
41
|
-
};
|
package/lib/webpack.config.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
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.getWebpackConfig = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
9
|
-
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
10
|
-
const getWebpackBuildMode = (qpqConfig) => {
|
|
11
|
-
const feature = quidproquo_core_1.qpqCoreUtils.getAppFeature(qpqConfig);
|
|
12
|
-
if (['development', 'production'].indexOf(feature) >= 0) {
|
|
13
|
-
return feature;
|
|
14
|
-
}
|
|
15
|
-
return 'production';
|
|
16
|
-
};
|
|
17
|
-
const getWebpackConfig = (qpqConfig, buildPath, outputPrefix) => {
|
|
18
|
-
const allSrcEntries = [
|
|
19
|
-
...quidproquo_core_1.qpqCoreUtils.getAllSrcEntries(qpqConfig),
|
|
20
|
-
...quidproquo_webserver_1.qpqWebServerUtils.getAllSrcEntries(qpqConfig),
|
|
21
|
-
];
|
|
22
|
-
// set the qpq config env for loaders
|
|
23
|
-
process.env.QPQLoaderConfig = JSON.stringify({
|
|
24
|
-
allSrcEntries,
|
|
25
|
-
rootDir: path_1.default.resolve(buildPath, '..'),
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
// entry: allSrcEntries.reduce(
|
|
29
|
-
// (entry, path) => ({
|
|
30
|
-
// ...entry,
|
|
31
|
-
// [`./${outputPrefix}/${path}`]: `./${path}`,
|
|
32
|
-
// }),
|
|
33
|
-
// {},
|
|
34
|
-
// ),
|
|
35
|
-
entry: {
|
|
36
|
-
lambdaAPIGatewayEvent: 'quidproquo-deploy-awscdk/src/lambdas/LambdaAPIGatewayEvent.ts',
|
|
37
|
-
lambdaEventBridgeEvent: 'quidproquo-deploy-awscdk/src/lambdas/lambdaEventBridgeEvent.ts',
|
|
38
|
-
},
|
|
39
|
-
resolveLoader: {
|
|
40
|
-
modules: [path_1.default.resolve(__dirname, 'loaders'), 'node_modules'],
|
|
41
|
-
},
|
|
42
|
-
// mode: getWebpackBuildMode(qpqConfig),
|
|
43
|
-
mode: 'production',
|
|
44
|
-
// We should: sort out how to split the bundles and get it to work on aws
|
|
45
|
-
// optimization: {
|
|
46
|
-
// splitChunks: {
|
|
47
|
-
// // include all types of chunks
|
|
48
|
-
// chunks: "all",
|
|
49
|
-
// },
|
|
50
|
-
// },
|
|
51
|
-
target: 'node',
|
|
52
|
-
output: {
|
|
53
|
-
// Output path
|
|
54
|
-
path: buildPath,
|
|
55
|
-
filename: '[name].js',
|
|
56
|
-
// Allow compiling as a lib ~ don't tree shake my exports plz
|
|
57
|
-
globalObject: 'this',
|
|
58
|
-
libraryTarget: 'commonjs2',
|
|
59
|
-
},
|
|
60
|
-
resolve: {
|
|
61
|
-
extensions: ['.ts', '.tsx', '.js', '.json'],
|
|
62
|
-
fallback: {
|
|
63
|
-
crypto: false,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
module: {
|
|
67
|
-
rules: [
|
|
68
|
-
{
|
|
69
|
-
test: /\.(ts)$/,
|
|
70
|
-
loader: 'babel-loader',
|
|
71
|
-
options: {
|
|
72
|
-
// without additional settings, this will reference .babelrc
|
|
73
|
-
presets: ['@babel/preset-typescript'],
|
|
74
|
-
},
|
|
75
|
-
exclude: /node_modules/,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
test: /\.(yaml|json)$/,
|
|
79
|
-
type: 'asset/source',
|
|
80
|
-
exclude: /node_modules/,
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
exports.getWebpackConfig = getWebpackConfig;
|