lwr 0.6.5 → 0.7.0-alpha.10
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 +10 -0
- package/build/cjs/cli/cli.cjs +17 -2
- package/build/cjs/cli/commands/bundle-lambda.cjs +116 -0
- package/build/cjs/cli/commands/shims/esm-require-shim.cjs +34 -0
- package/build/cjs/cli/commands/shims/lwr-lambda-shim.cjs +30 -0
- package/build/es/cli/cli.js +22 -2
- package/build/es/cli/commands/bundle-lambda.d.ts +8 -0
- package/build/es/cli/commands/bundle-lambda.js +104 -0
- package/build/es/cli/commands/shims/esm-require-shim.d.ts +3 -0
- package/build/es/cli/commands/shims/esm-require-shim.js +24 -0
- package/build/es/cli/commands/shims/lwr-lambda-shim.d.ts +3 -0
- package/build/es/cli/commands/shims/lwr-lambda-shim.js +19 -0
- package/package.json +8 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MIT LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Salesforce.com, Inc.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/build/cjs/cli/cli.cjs
CHANGED
|
@@ -32,7 +32,7 @@ cli.command("").action((o) => {
|
|
|
32
32
|
cli.outputHelp();
|
|
33
33
|
process.exit(1);
|
|
34
34
|
});
|
|
35
|
-
cli.command("serve", "Starts an LWR server (defaults to dev mode)").alias("dev").option("--port <port>", `[number] specify port`).option("--mode <mode>", "[string] server mode").option("--open
|
|
35
|
+
cli.command("serve", "Starts an LWR server (defaults to dev mode)").alias("dev").option("--port <port>", `[number] specify port`).option("--mode <mode>", "[string] server mode").option("--open <path>", `[boolean | string] open browser on startup`).action(async (options) => {
|
|
36
36
|
const {createServer} = await Promise.resolve().then(() => __toModule(require("@lwrjs/core")));
|
|
37
37
|
const {port, mode = "dev", open} = options;
|
|
38
38
|
try {
|
|
@@ -52,7 +52,7 @@ cli.command("serve", "Starts an LWR server (defaults to dev mode)").alias("dev")
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
cli.command("build", "Builds a static LWR site").alias("static-build").option("--outputDir
|
|
55
|
+
cli.command("build", "Builds a static LWR site").alias("static-build").option("--outputDir <directory>", `[string] output directory`).action(async (options) => {
|
|
56
56
|
const {output = "__generated_site__"} = options;
|
|
57
57
|
const {generateStaticSite} = await Promise.resolve().then(() => __toModule(require("@lwrjs/core")));
|
|
58
58
|
try {
|
|
@@ -72,6 +72,21 @@ cli.command("build", "Builds a static LWR site").alias("static-build").option("-
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
|
+
cli.command("bundle-lambda", "Bundles the lambda source").option("--entryPoint <entry>", "[string] bundling entry point").option("--format <format>", "[string] bundle output format").action(async (options) => {
|
|
76
|
+
const entryPoint = options.entryPoint || "./src/index.ts";
|
|
77
|
+
const format = options.format || "esm";
|
|
78
|
+
try {
|
|
79
|
+
const {bundleLambda} = await Promise.resolve().then(() => __toModule(require("./commands/bundle-lambda.cjs")));
|
|
80
|
+
await bundleLambda({entryPoint, format});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (error instanceof import_diagnostics.DiagnosticsError) {
|
|
83
|
+
console.log(error.diagnostics);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
} else {
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
75
90
|
cli.on("command:*", () => {
|
|
76
91
|
console.error(import_chalk.default.redBright(`Invalid command: ${cli.args.join(" ")}`));
|
|
77
92
|
cli.outputHelp();
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __exportStar = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toModule = (module2) => {
|
|
21
|
+
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/lwr/src/cli/commands/bundle-lambda.ts
|
|
25
|
+
__markAsModule(exports);
|
|
26
|
+
__export(exports, {
|
|
27
|
+
bundleLambda: () => bundleLambda
|
|
28
|
+
});
|
|
29
|
+
var import_fs = __toModule(require("fs"));
|
|
30
|
+
var import_path = __toModule(require("path"));
|
|
31
|
+
var import_esbuild = __toModule(require("esbuild"));
|
|
32
|
+
var import_vm2 = __toModule(require("vm2"));
|
|
33
|
+
var import_core = __toModule(require("@lwrjs/core"));
|
|
34
|
+
var import_esm_require_shim = __toModule(require("./shims/esm-require-shim.cjs"));
|
|
35
|
+
var import_lwr_lambda_shim = __toModule(require("./shims/lwr-lambda-shim.cjs"));
|
|
36
|
+
async function bundleLambda({entryPoint, format}) {
|
|
37
|
+
const arg = await getConfigArg(entryPoint);
|
|
38
|
+
const server = (0, import_core.createServer)(arg);
|
|
39
|
+
const config = server.getConfig();
|
|
40
|
+
const lambdaShim = generateLambdaShim(config);
|
|
41
|
+
const buildDir = import_path.default.resolve("./build/generated");
|
|
42
|
+
const lambdaShimPath = import_path.default.join(buildDir, "lwr-lambda-shim.js");
|
|
43
|
+
import_fs.default.mkdirSync(buildDir, {recursive: true});
|
|
44
|
+
import_fs.default.writeFileSync(lambdaShimPath, lambdaShim);
|
|
45
|
+
const options = {
|
|
46
|
+
bundle: true,
|
|
47
|
+
format,
|
|
48
|
+
treeShaking: true,
|
|
49
|
+
entryPoints: [entryPoint],
|
|
50
|
+
outdir: "./build",
|
|
51
|
+
platform: "node",
|
|
52
|
+
external: ["fsevents", "esbuild", "rollup", "esinstall", "rollup-plugin-node-polyfills"],
|
|
53
|
+
inject: [lambdaShimPath]
|
|
54
|
+
};
|
|
55
|
+
if (format === "esm") {
|
|
56
|
+
options.banner = {
|
|
57
|
+
js: import_esm_require_shim.default
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
(0, import_esbuild.build)(options);
|
|
61
|
+
}
|
|
62
|
+
async function getConfigArg(entryPoint) {
|
|
63
|
+
const result = await (0, import_esbuild.build)({
|
|
64
|
+
entryPoints: [entryPoint],
|
|
65
|
+
bundle: true,
|
|
66
|
+
write: false,
|
|
67
|
+
format: "cjs",
|
|
68
|
+
platform: "node",
|
|
69
|
+
external: [
|
|
70
|
+
"@lwrjs/lambda"
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
const lambda = result.outputFiles[0].text;
|
|
74
|
+
const vm = new import_vm2.NodeVM({
|
|
75
|
+
console: "inherit",
|
|
76
|
+
sandbox: {},
|
|
77
|
+
require: {
|
|
78
|
+
external: true,
|
|
79
|
+
builtin: ["*"],
|
|
80
|
+
root: [import_path.default.dirname(entryPoint)],
|
|
81
|
+
mock: {
|
|
82
|
+
"@lwrjs/lambda": {
|
|
83
|
+
createHandler: (arg) => {
|
|
84
|
+
return arg;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
try {
|
|
91
|
+
const {get} = vm.run(lambda);
|
|
92
|
+
return get;
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error(e);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function generateLambdaShim(config) {
|
|
99
|
+
const serviceCtors = [];
|
|
100
|
+
const services = [];
|
|
101
|
+
const serviceConfigs = [];
|
|
102
|
+
for (const [index, [servicePath, serviceConfig = {}]] of config.moduleProviders.entries()) {
|
|
103
|
+
serviceCtors.push(`import ServiceCtor${index} from '${servicePath}';`);
|
|
104
|
+
services.push(`ServiceCtor${index}`);
|
|
105
|
+
serviceConfigs.push(JSON.stringify(serviceConfig));
|
|
106
|
+
}
|
|
107
|
+
const hookCtors = [];
|
|
108
|
+
const hooks = [];
|
|
109
|
+
const hookConfigs = [];
|
|
110
|
+
for (const [index, [hookPath, hookConfig = {}]] of config.moduleProviders.entries()) {
|
|
111
|
+
hookCtors.push(`import HookCtor${index} from '${hookPath}';`);
|
|
112
|
+
hooks.push(`HookCtor${index}`);
|
|
113
|
+
hookConfigs.push(JSON.stringify(hookConfig));
|
|
114
|
+
}
|
|
115
|
+
return import_lwr_lambda_shim.default.replace("{ serviceCtors }", serviceCtors.join("\n")).replace("{ services }", services.join()).replace("{ serviceConfigs }", serviceConfigs.join()).replace("{ hookCtors }", hookCtors.join("\n")).replace("{ hooks }", hooks.join()).replace("{ hookConfigs }", hookConfigs.join());
|
|
116
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// packages/lwr/src/cli/commands/shims/esm-require-shim.ts
|
|
9
|
+
__markAsModule(exports);
|
|
10
|
+
__export(exports, {
|
|
11
|
+
default: () => esm_require_shim_default
|
|
12
|
+
});
|
|
13
|
+
var esm_require_shim_default = `
|
|
14
|
+
await (async () => {
|
|
15
|
+
const { dirname } = await import("path");
|
|
16
|
+
const { fileURLToPath } = await import("url");
|
|
17
|
+
/**
|
|
18
|
+
* Shim entry-point related paths.
|
|
19
|
+
*/
|
|
20
|
+
if (typeof globalThis.__filename === "undefined") {
|
|
21
|
+
globalThis.__filename = fileURLToPath(import.meta.url);
|
|
22
|
+
}
|
|
23
|
+
if (typeof globalThis.__dirname === "undefined") {
|
|
24
|
+
globalThis.__dirname = dirname(globalThis.__filename);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Shim require if needed.
|
|
28
|
+
*/
|
|
29
|
+
if (typeof globalThis.require === "undefined") {
|
|
30
|
+
const { default: module } = await import("module");
|
|
31
|
+
globalThis.require = module.createRequire(import.meta.url);
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
34
|
+
`;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// packages/lwr/src/cli/commands/shims/lwr-lambda-shim.ts
|
|
9
|
+
__markAsModule(exports);
|
|
10
|
+
__export(exports, {
|
|
11
|
+
default: () => lwr_lambda_shim_default
|
|
12
|
+
});
|
|
13
|
+
var lwr_lambda_shim_default = `
|
|
14
|
+
{ serviceCtors }
|
|
15
|
+
{ hookCtors }
|
|
16
|
+
export const LWR = {
|
|
17
|
+
getModuleProviders: (context) => {
|
|
18
|
+
const serviceConfigs = [{ serviceConfigs }];
|
|
19
|
+
return [{ services }].map((ServiceCtor, index) => {
|
|
20
|
+
return new ServiceCtor(serviceConfigs[index], context);
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
getHooks: () => {
|
|
24
|
+
const hookConfigs = [{ hookConfigs }];
|
|
25
|
+
return [{ hooks }].map((HookCtor, index) => {
|
|
26
|
+
return new HookCtor(hookConfigs[index]);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
`;
|
package/build/es/cli/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ cli.command('serve', 'Starts an LWR server (defaults to dev mode)')
|
|
|
24
24
|
.alias('dev')
|
|
25
25
|
.option('--port <port>', `[number] specify port`)
|
|
26
26
|
.option('--mode <mode>', '[string] server mode')
|
|
27
|
-
.option('--open
|
|
27
|
+
.option('--open <path>', `[boolean | string] open browser on startup`)
|
|
28
28
|
// .option('--https', `[boolean] use TLS + HTTP/2`)
|
|
29
29
|
// .option('--strictPort', `[boolean] exit if specified port is already in use`)
|
|
30
30
|
// .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
@@ -52,7 +52,7 @@ cli.command('serve', 'Starts an LWR server (defaults to dev mode)')
|
|
|
52
52
|
});
|
|
53
53
|
cli.command('build', 'Builds a static LWR site') // default command
|
|
54
54
|
.alias('static-build')
|
|
55
|
-
.option('--outputDir
|
|
55
|
+
.option('--outputDir <directory>', `[string] output directory`)
|
|
56
56
|
.action(async (options) => {
|
|
57
57
|
const { output = '__generated_site__' } = options;
|
|
58
58
|
const { generateStaticSite } = await import('@lwrjs/core');
|
|
@@ -75,6 +75,26 @@ cli.command('build', 'Builds a static LWR site') // default command
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
+
cli.command('bundle-lambda', 'Bundles the lambda source')
|
|
79
|
+
.option('--entryPoint <entry>', '[string] bundling entry point')
|
|
80
|
+
.option('--format <format>', '[string] bundle output format')
|
|
81
|
+
.action(async (options) => {
|
|
82
|
+
const entryPoint = options.entryPoint || './src/index.ts';
|
|
83
|
+
const format = options.format || 'esm';
|
|
84
|
+
try {
|
|
85
|
+
const { bundleLambda } = await import('./commands/bundle-lambda.js');
|
|
86
|
+
await bundleLambda({ entryPoint, format });
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error instanceof DiagnosticsError) {
|
|
90
|
+
console.log(error.diagnostics);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
78
98
|
cli.on('command:*', () => {
|
|
79
99
|
console.error(chalk.redBright(`Invalid command: ${cli.args.join(' ')}`));
|
|
80
100
|
cli.outputHelp();
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { build } from 'esbuild';
|
|
4
|
+
import { NodeVM } from 'vm2';
|
|
5
|
+
import { createServer } from '@lwrjs/core';
|
|
6
|
+
import ESM_REQUIRE_SHIM from './shims/esm-require-shim.js';
|
|
7
|
+
import LWR_LAMBDA_SHIM from './shims/lwr-lambda-shim.js';
|
|
8
|
+
export async function bundleLambda({ entryPoint, format }) {
|
|
9
|
+
// get createHandler config argument
|
|
10
|
+
const arg = await getConfigArg(entryPoint);
|
|
11
|
+
// HACK: creating server just for config loading
|
|
12
|
+
const server = createServer(arg);
|
|
13
|
+
const config = server.getConfig();
|
|
14
|
+
// generate the lambda shim source
|
|
15
|
+
const lambdaShim = generateLambdaShim(config);
|
|
16
|
+
const buildDir = path.resolve('./build/generated');
|
|
17
|
+
const lambdaShimPath = path.join(buildDir, 'lwr-lambda-shim.js');
|
|
18
|
+
fs.mkdirSync(buildDir, { recursive: true });
|
|
19
|
+
fs.writeFileSync(lambdaShimPath, lambdaShim);
|
|
20
|
+
// bundle lambda handler and inject the lwr shim
|
|
21
|
+
const options = {
|
|
22
|
+
bundle: true,
|
|
23
|
+
format,
|
|
24
|
+
treeShaking: true,
|
|
25
|
+
entryPoints: [entryPoint],
|
|
26
|
+
outdir: './build',
|
|
27
|
+
platform: 'node',
|
|
28
|
+
external: ['fsevents', 'esbuild', 'rollup', 'esinstall', 'rollup-plugin-node-polyfills'],
|
|
29
|
+
inject: [lambdaShimPath],
|
|
30
|
+
};
|
|
31
|
+
if (format === 'esm') {
|
|
32
|
+
options.banner = {
|
|
33
|
+
js: ESM_REQUIRE_SHIM,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
build(options);
|
|
37
|
+
}
|
|
38
|
+
async function getConfigArg(entryPoint) {
|
|
39
|
+
// bundle lambda source for execution in a sandbox
|
|
40
|
+
const result = await build({
|
|
41
|
+
entryPoints: [entryPoint],
|
|
42
|
+
bundle: true,
|
|
43
|
+
write: false,
|
|
44
|
+
format: 'cjs',
|
|
45
|
+
platform: 'node',
|
|
46
|
+
external: [
|
|
47
|
+
// skip @lwrjs/lambda because it will be mocked at execution
|
|
48
|
+
'@lwrjs/lambda',
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
// execute lambda source with mocked createHandler to capture config
|
|
52
|
+
const lambda = result.outputFiles[0].text;
|
|
53
|
+
const vm = new NodeVM({
|
|
54
|
+
console: 'inherit',
|
|
55
|
+
sandbox: {},
|
|
56
|
+
require: {
|
|
57
|
+
external: true,
|
|
58
|
+
builtin: ['*'],
|
|
59
|
+
root: [path.dirname(entryPoint)],
|
|
60
|
+
mock: {
|
|
61
|
+
'@lwrjs/lambda': {
|
|
62
|
+
createHandler: (arg) => {
|
|
63
|
+
return arg;
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
try {
|
|
70
|
+
const { get } = vm.run(lambda);
|
|
71
|
+
return get;
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
console.error(e);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function generateLambdaShim(config) {
|
|
79
|
+
const serviceCtors = [];
|
|
80
|
+
const services = [];
|
|
81
|
+
const serviceConfigs = [];
|
|
82
|
+
// module provider generation
|
|
83
|
+
for (const [index, [servicePath, serviceConfig = {}]] of config.moduleProviders.entries()) {
|
|
84
|
+
serviceCtors.push(`import ServiceCtor${index} from '${servicePath}';`);
|
|
85
|
+
services.push(`ServiceCtor${index}`);
|
|
86
|
+
serviceConfigs.push(JSON.stringify(serviceConfig));
|
|
87
|
+
}
|
|
88
|
+
const hookCtors = [];
|
|
89
|
+
const hooks = [];
|
|
90
|
+
const hookConfigs = [];
|
|
91
|
+
// hooks generation
|
|
92
|
+
for (const [index, [hookPath, hookConfig = {}]] of config.moduleProviders.entries()) {
|
|
93
|
+
hookCtors.push(`import HookCtor${index} from '${hookPath}';`);
|
|
94
|
+
hooks.push(`HookCtor${index}`);
|
|
95
|
+
hookConfigs.push(JSON.stringify(hookConfig));
|
|
96
|
+
}
|
|
97
|
+
return LWR_LAMBDA_SHIM.replace('{ serviceCtors }', serviceCtors.join('\n'))
|
|
98
|
+
.replace('{ services }', services.join())
|
|
99
|
+
.replace('{ serviceConfigs }', serviceConfigs.join())
|
|
100
|
+
.replace('{ hookCtors }', hookCtors.join('\n'))
|
|
101
|
+
.replace('{ hooks }', hooks.join())
|
|
102
|
+
.replace('{ hookConfigs }', hookConfigs.join());
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=bundle-lambda.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: "\nawait (async () => {\n const { dirname } = await import(\"path\");\n const { fileURLToPath } = await import(\"url\");\n /**\n * Shim entry-point related paths.\n */\n if (typeof globalThis.__filename === \"undefined\") {\n globalThis.__filename = fileURLToPath(import.meta.url);\n }\n if (typeof globalThis.__dirname === \"undefined\") {\n globalThis.__dirname = dirname(globalThis.__filename);\n }\n /**\n * Shim require if needed.\n */\n if (typeof globalThis.require === \"undefined\") {\n const { default: module } = await import(\"module\");\n globalThis.require = module.createRequire(import.meta.url);\n }\n})();\n";
|
|
2
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=esm-require-shim.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// work-around copied from: https://github.com/evanw/esbuild/pull/2067#issuecomment-1073039746
|
|
2
|
+
export default `
|
|
3
|
+
await (async () => {
|
|
4
|
+
const { dirname } = await import("path");
|
|
5
|
+
const { fileURLToPath } = await import("url");
|
|
6
|
+
/**
|
|
7
|
+
* Shim entry-point related paths.
|
|
8
|
+
*/
|
|
9
|
+
if (typeof globalThis.__filename === "undefined") {
|
|
10
|
+
globalThis.__filename = fileURLToPath(import.meta.url);
|
|
11
|
+
}
|
|
12
|
+
if (typeof globalThis.__dirname === "undefined") {
|
|
13
|
+
globalThis.__dirname = dirname(globalThis.__filename);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Shim require if needed.
|
|
17
|
+
*/
|
|
18
|
+
if (typeof globalThis.require === "undefined") {
|
|
19
|
+
const { default: module } = await import("module");
|
|
20
|
+
globalThis.require = module.createRequire(import.meta.url);
|
|
21
|
+
}
|
|
22
|
+
})();
|
|
23
|
+
`;
|
|
24
|
+
//# sourceMappingURL=esm-require-shim.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: "\n{ serviceCtors }\n{ hookCtors }\nexport const LWR = {\n getModuleProviders: (context) => {\n const serviceConfigs = [{ serviceConfigs }];\n return [{ services }].map((ServiceCtor, index) => {\n return new ServiceCtor(serviceConfigs[index], context);\n });\n },\n getHooks: () => {\n const hookConfigs = [{ hookConfigs }];\n return [{ hooks }].map((HookCtor, index) => {\n return new HookCtor(hookConfigs[index]);\n });\n }\n};\n";
|
|
2
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=lwr-lambda-shim.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default `
|
|
2
|
+
{ serviceCtors }
|
|
3
|
+
{ hookCtors }
|
|
4
|
+
export const LWR = {
|
|
5
|
+
getModuleProviders: (context) => {
|
|
6
|
+
const serviceConfigs = [{ serviceConfigs }];
|
|
7
|
+
return [{ services }].map((ServiceCtor, index) => {
|
|
8
|
+
return new ServiceCtor(serviceConfigs[index], context);
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
getHooks: () => {
|
|
12
|
+
const hookConfigs = [{ hookConfigs }];
|
|
13
|
+
return [{ hooks }].map((HookCtor, index) => {
|
|
14
|
+
return new HookCtor(hookConfigs[index]);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
`;
|
|
19
|
+
//# sourceMappingURL=lwr-lambda-shim.js.map
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"types": "build/es/index.d.ts",
|
|
21
|
-
"version": "0.
|
|
21
|
+
"version": "0.7.0-alpha.10",
|
|
22
22
|
"module": "build/es/index.js",
|
|
23
23
|
"main": "build/cjs/index.cjs",
|
|
24
24
|
"files": [
|
|
@@ -38,8 +38,11 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@lwrjs/core": "0.
|
|
42
|
-
"@lwrjs/types": "0.
|
|
43
|
-
"cac": "^6.7.8"
|
|
44
|
-
|
|
41
|
+
"@lwrjs/core": "0.7.0-alpha.10",
|
|
42
|
+
"@lwrjs/types": "0.7.0-alpha.10",
|
|
43
|
+
"cac": "^6.7.8",
|
|
44
|
+
"esbuild": "^0.14.38",
|
|
45
|
+
"vm2": "^3.9.9"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "83c1e65e2169094cb55ac2c37e5aef16d3a9aa4a"
|
|
45
48
|
}
|