@goldstack/template-ssr-server 0.1.7 → 0.1.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/dist/src/templateSSRServer.d.ts +4 -2
- package/dist/src/templateSSRServer.d.ts.map +1 -1
- package/dist/src/templateSSRServer.js +6 -6
- package/dist/src/templateSSRServer.js.map +1 -1
- package/package.json +16 -18
- package/dist/src/compileBundle.d.ts +0 -21
- package/dist/src/compileBundle.d.ts.map +0 -1
- package/dist/src/compileBundle.js +0 -138
- package/dist/src/compileBundle.js.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda';
|
|
3
|
+
import type { ESBuildConfiguration } from '@goldstack/template-ssr-server-compile-bundle';
|
|
4
|
+
export type { ESBuildConfiguration };
|
|
3
5
|
export declare const clientBundleFileName = "client.bundle.js";
|
|
4
6
|
export declare const clientCSSFileName = "client.bundle.css";
|
|
5
|
-
export { compileBundle } from './compileBundle';
|
|
6
7
|
export interface RenderDocumentProps {
|
|
7
8
|
bundledJsPath: string;
|
|
8
9
|
styles?: string;
|
|
@@ -14,6 +15,7 @@ export interface RenderPageProps<PropType> {
|
|
|
14
15
|
renderDocument: (props: RenderDocumentProps) => string;
|
|
15
16
|
component: React.FunctionComponent<PropType>;
|
|
16
17
|
properties: PropType;
|
|
18
|
+
esbuildConfig: () => ESBuildConfiguration;
|
|
17
19
|
}
|
|
18
|
-
export declare const renderPage: <PropType>({ entryPoint, event, renderDocument, component, properties, }: RenderPageProps<PropType>) => Promise<APIGatewayProxyResultV2>;
|
|
20
|
+
export declare const renderPage: <PropType>({ entryPoint, event, renderDocument, component, properties, esbuildConfig, }: RenderPageProps<PropType>) => Promise<APIGatewayProxyResultV2>;
|
|
19
21
|
//# sourceMappingURL=templateSSRServer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateSSRServer.d.ts","sourceRoot":"","sources":["../../src/templateSSRServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAQpB,
|
|
1
|
+
{"version":3,"file":"templateSSRServer.d.ts","sourceRoot":"","sources":["../../src/templateSSRServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAQpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAE1F,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAErC,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe,CAAC,QAAQ;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,cAAc,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,MAAM,CAAC;IACvD,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC7C,UAAU,EAAE,QAAQ,CAAC;IACrB,aAAa,EAAE,MAAM,oBAAoB,CAAC;CAC3C;AAED,eAAO,MAAM,UAAU,yHAOQ,QAAQ,uBAAuB,CA8E7D,CAAC"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.renderPage = exports.
|
|
6
|
+
exports.renderPage = exports.clientCSSFileName = exports.clientBundleFileName = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const lambda_compression_1 = require("lambda-compression");
|
|
9
9
|
const server_1 = require("react-dom/server");
|
|
@@ -11,9 +11,7 @@ const utils_esbuild_1 = require("@goldstack/utils-esbuild");
|
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
exports.clientBundleFileName = 'client.bundle.js';
|
|
13
13
|
exports.clientCSSFileName = 'client.bundle.css';
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(exports, "compileBundle", { enumerable: true, get: function () { return compileBundle_1.compileBundle; } });
|
|
16
|
-
const renderPage = async ({ entryPoint, event, renderDocument, component, properties, }) => {
|
|
14
|
+
const renderPage = async ({ entryPoint, event, renderDocument, component, properties, esbuildConfig, }) => {
|
|
17
15
|
if (event.queryStringParameters && event.queryStringParameters['resource']) {
|
|
18
16
|
if (event.queryStringParameters['resource'].indexOf('js') > -1) {
|
|
19
17
|
if (process.env.AWS_LAMBDA_FUNCTION_NAME) {
|
|
@@ -31,9 +29,10 @@ const renderPage = async ({ entryPoint, event, renderDocument, component, proper
|
|
|
31
29
|
// if not running in Lambda build bundle dynamically
|
|
32
30
|
return (0, lambda_compression_1.compress)(event,
|
|
33
31
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
34
|
-
require((0, utils_esbuild_1.excludeInBundle)('
|
|
32
|
+
require((0, utils_esbuild_1.excludeInBundle)('@goldstack/template-ssr-server-compile-bundle')).bundleResponse({
|
|
35
33
|
entryPoint,
|
|
36
34
|
initialProperties: properties,
|
|
35
|
+
esbuildConfig: esbuildConfig(),
|
|
37
36
|
}));
|
|
38
37
|
}
|
|
39
38
|
}
|
|
@@ -51,8 +50,9 @@ const renderPage = async ({ entryPoint, event, renderDocument, component, proper
|
|
|
51
50
|
else {
|
|
52
51
|
return (0, lambda_compression_1.compress)(event,
|
|
53
52
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
54
|
-
require((0, utils_esbuild_1.excludeInBundle)('
|
|
53
|
+
require((0, utils_esbuild_1.excludeInBundle)('@goldstack/template-ssr-server-compile-bundle')).sourceMapResponse({
|
|
55
54
|
entryPoint,
|
|
55
|
+
esbuildConfig: esbuildConfig(),
|
|
56
56
|
}));
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateSSRServer.js","sourceRoot":"","sources":["../../src/templateSSRServer.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAO1B,2DAA8C;AAE9C,6CAAkD;AAClD,4DAA2D;AAC3D,2BAAkC;
|
|
1
|
+
{"version":3,"file":"templateSSRServer.js","sourceRoot":"","sources":["../../src/templateSSRServer.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAO1B,2DAA8C;AAE9C,6CAAkD;AAClD,4DAA2D;AAC3D,2BAAkC;AAMrB,QAAA,oBAAoB,GAAG,kBAAkB,CAAC;AAC1C,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AAiB9C,MAAM,UAAU,GAAG,KAAK,EAAY,EACzC,UAAU,EACV,KAAK,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,aAAa,GACa,EAAoC,EAAE;IAChE,IAAI,KAAK,CAAC,qBAAqB,IAAI,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE;QAC1E,IAAI,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;YAC9D,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE;gBACxC,0DAA0D;gBAC1D,OAAO,IAAA,6BAAQ,EAAC,KAAK,EAAE;oBACrB,UAAU,EAAE,GAAG;oBACf,OAAO,EAAE;wBACP,cAAc,EAAE,wBAAwB;wBACxC,SAAS,EAAE,qBAAqB;qBACjC;oBACD,IAAI,EAAE,4BAA4B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BAAiB,EAAE,OAAO,CAAC,CAAC;KACnD;SAAM;QACL,MAAM,GAAG,SAAS,CAAC;KACpB;IAED,MAAM,QAAQ,GAAG,cAAc,CAAC;QAC9B,aAAa,EAAE,cAAc;QAC7B,MAAM;QACN,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;IACH,OAAO,IAAA,6BAAQ,EAAC,KAAK,EAAE;QACrB,UAAU,EAAE,GAAG;QACf,OAAO,EAAE;YACP,cAAc,EAAE,WAAW;SAC5B;QACD,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;AACL,CAAC,CAAC;AArFW,QAAA,UAAU,cAqFrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goldstack/template-ssr-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Building blocks for implementing server-side rendered pages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"goldstack",
|
|
@@ -38,30 +38,28 @@
|
|
|
38
38
|
"version:apply:force": "yarn version $@ && yarn version apply"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@goldstack/infra": "0.3.
|
|
42
|
-
"@goldstack/infra-aws": "0.3.
|
|
43
|
-
"@goldstack/
|
|
44
|
-
"@goldstack/utils-
|
|
45
|
-
"@goldstack/utils-
|
|
46
|
-
"@goldstack/utils-package
|
|
47
|
-
"@goldstack/utils-
|
|
48
|
-
"@goldstack/utils-
|
|
49
|
-
"@goldstack/utils-
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
"esbuild-css-modules-client-plugin": "0.1.4",
|
|
53
|
-
"lambda-compression": "0.1.2",
|
|
41
|
+
"@goldstack/infra": "0.3.40",
|
|
42
|
+
"@goldstack/infra-aws": "0.3.49",
|
|
43
|
+
"@goldstack/template-ssr-server-compile-bundle": "0.1.3",
|
|
44
|
+
"@goldstack/utils-aws-lambda": "0.1.39",
|
|
45
|
+
"@goldstack/utils-esbuild": "0.4.4",
|
|
46
|
+
"@goldstack/utils-package": "0.3.43",
|
|
47
|
+
"@goldstack/utils-package-config-embedded": "0.4.7",
|
|
48
|
+
"@goldstack/utils-sh": "0.4.35",
|
|
49
|
+
"@goldstack/utils-template": "0.3.39",
|
|
50
|
+
"@goldstack/utils-terraform": "0.3.73",
|
|
51
|
+
"lambda-compression": "0.1.3",
|
|
54
52
|
"react": "^18.2.0",
|
|
55
53
|
"react-dom": "^18.2.0",
|
|
56
54
|
"source-map-support": "^0.5.21"
|
|
57
55
|
},
|
|
58
56
|
"devDependencies": {
|
|
59
57
|
"@goldstack/utils-docs-cli": "0.3.11",
|
|
60
|
-
"@goldstack/utils-git": "0.1.
|
|
61
|
-
"@goldstack/utils-package-config-generate": "0.2.
|
|
58
|
+
"@goldstack/utils-git": "0.1.37",
|
|
59
|
+
"@goldstack/utils-package-config-generate": "0.2.18",
|
|
62
60
|
"@types/aws-lambda": "^8.10.88",
|
|
63
|
-
"@types/jest": "^
|
|
64
|
-
"@types/node": "^
|
|
61
|
+
"@types/jest": "^28.1.8",
|
|
62
|
+
"@types/node": "^18.7.13",
|
|
65
63
|
"@types/react": "^18.0.15",
|
|
66
64
|
"@types/sha256": "^0",
|
|
67
65
|
"@types/yargs": "^17.0.10",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { APIGatewayProxyResultV2 } from 'aws-lambda';
|
|
2
|
-
export interface CompileBundleResponse {
|
|
3
|
-
bundle: string;
|
|
4
|
-
sourceMap?: string;
|
|
5
|
-
metaFile?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const compileBundle: ({ entryPoint, metaFile, sourceMap, initialProperties, includeCss, }: {
|
|
8
|
-
entryPoint: string;
|
|
9
|
-
metaFile?: boolean | undefined;
|
|
10
|
-
sourceMap?: boolean | undefined;
|
|
11
|
-
initialProperties?: any;
|
|
12
|
-
includeCss: boolean;
|
|
13
|
-
}) => Promise<CompileBundleResponse>;
|
|
14
|
-
export declare const bundleResponse: ({ entryPoint, initialProperties, }: {
|
|
15
|
-
entryPoint: string;
|
|
16
|
-
initialProperties?: any;
|
|
17
|
-
}) => Promise<APIGatewayProxyResultV2>;
|
|
18
|
-
export declare const sourceMapResponse: ({ entryPoint, }: {
|
|
19
|
-
entryPoint: string;
|
|
20
|
-
}) => Promise<APIGatewayProxyResultV2>;
|
|
21
|
-
//# sourceMappingURL=compileBundle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compileBundle.d.ts","sourceRoot":"","sources":["../../src/compileBundle.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAoCrD,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAsBD,eAAO,MAAM,aAAa;gBAOZ,MAAM;;;wBAGE,GAAG;gBACX,OAAO;MACjB,QAAQ,qBAAqB,CAyChC,CAAC;AAEF,eAAO,MAAM,cAAc;gBAIb,MAAM;wBACE,GAAG;MACrB,QAAQ,uBAAuB,CAkBlC,CAAC;AAoBF,eAAO,MAAM,iBAAiB;gBAGhB,MAAM;MAChB,QAAQ,uBAAuB,CAsBlC,CAAC"}
|
|
@@ -1,138 +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.sourceMapResponse = exports.bundleResponse = exports.compileBundle = void 0;
|
|
7
|
-
const esbuild_1 = require("esbuild");
|
|
8
|
-
const esbuild_plugin_pnp_1 = require("@yarnpkg/esbuild-plugin-pnp");
|
|
9
|
-
const esbuild_css_modules_client_plugin_1 = __importDefault(require("esbuild-css-modules-client-plugin"));
|
|
10
|
-
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
const sharedConfig = (includeCss) => {
|
|
13
|
-
return {
|
|
14
|
-
plugins: [
|
|
15
|
-
(0, esbuild_css_modules_client_plugin_1.default)({
|
|
16
|
-
excludeCSSInject: !includeCss,
|
|
17
|
-
}),
|
|
18
|
-
(0, esbuild_plugin_pnp_1.pnpPlugin)(),
|
|
19
|
-
],
|
|
20
|
-
bundle: true,
|
|
21
|
-
outfile: '/dist/tmp/bundle.js',
|
|
22
|
-
external: [
|
|
23
|
-
'esbuild',
|
|
24
|
-
'@yarnpkg/esbuild-plugin-pnp',
|
|
25
|
-
'@goldstack/template-ssr-server', // this is only required on the server side
|
|
26
|
-
],
|
|
27
|
-
minify: true,
|
|
28
|
-
platform: 'browser',
|
|
29
|
-
format: 'iife',
|
|
30
|
-
treeShaking: true,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
const getEsBuildConfig = (entryPoint) => {
|
|
34
|
-
const esbuildConfig = (0, utils_sh_1.readToType)('./esbuild.config.json');
|
|
35
|
-
const esbuildLocalPath = (0, utils_sh_1.changeExtension)((0, path_1.dirname)(entryPoint), '.esbuild.config.json');
|
|
36
|
-
const localEsbuildConfig = (0, utils_sh_1.readToType)(esbuildLocalPath);
|
|
37
|
-
return { ...esbuildConfig, ...localEsbuildConfig };
|
|
38
|
-
};
|
|
39
|
-
const getOutput = (extension, result) => {
|
|
40
|
-
const matchedFiles = result.outputFiles.filter((file) => file.path.endsWith(extension));
|
|
41
|
-
if (matchedFiles.length !== 1) {
|
|
42
|
-
throw new Error(`Invalid output from esbuild. Expected only one '${extension}' file but found ${matchedFiles.length}`);
|
|
43
|
-
}
|
|
44
|
-
const output = Buffer.from(matchedFiles[0].contents).toString('utf-8');
|
|
45
|
-
return output;
|
|
46
|
-
};
|
|
47
|
-
const compileBundle = async ({ entryPoint, metaFile, sourceMap, initialProperties, includeCss, }) => {
|
|
48
|
-
const res = await (0, esbuild_1.build)({
|
|
49
|
-
...sharedConfig(includeCss),
|
|
50
|
-
entryPoints: [entryPoint],
|
|
51
|
-
metafile: metaFile,
|
|
52
|
-
sourcemap: sourceMap ? 'inline' : undefined,
|
|
53
|
-
...getEsBuildConfig(entryPoint),
|
|
54
|
-
write: false,
|
|
55
|
-
});
|
|
56
|
-
const output = getOutput('.js', res);
|
|
57
|
-
let result = {
|
|
58
|
-
bundle: '',
|
|
59
|
-
};
|
|
60
|
-
if (!sourceMap) {
|
|
61
|
-
result.bundle = output;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
result.bundle = removeSourceMap(output);
|
|
65
|
-
}
|
|
66
|
-
if (initialProperties) {
|
|
67
|
-
result.bundle = `window.initialProperties = ${JSON.stringify(initialProperties)};${result.bundle}`;
|
|
68
|
-
}
|
|
69
|
-
if (metaFile) {
|
|
70
|
-
result = {
|
|
71
|
-
...result,
|
|
72
|
-
metaFile: JSON.stringify(res.metafile),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (sourceMap) {
|
|
76
|
-
result = {
|
|
77
|
-
...result,
|
|
78
|
-
sourceMap: extractSourceMap(output),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
82
|
-
};
|
|
83
|
-
exports.compileBundle = compileBundle;
|
|
84
|
-
const bundleResponse = async ({ entryPoint, initialProperties, }) => {
|
|
85
|
-
const res = await (0, exports.compileBundle)({
|
|
86
|
-
entryPoint,
|
|
87
|
-
initialProperties,
|
|
88
|
-
includeCss: true,
|
|
89
|
-
});
|
|
90
|
-
return {
|
|
91
|
-
statusCode: 201,
|
|
92
|
-
headers: {
|
|
93
|
-
'Content-Type': 'application/javascript',
|
|
94
|
-
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
95
|
-
Pragma: 'no-cache',
|
|
96
|
-
Expire: '0',
|
|
97
|
-
SourceMap: '?resource=sourcemap',
|
|
98
|
-
},
|
|
99
|
-
body: res.bundle,
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
exports.bundleResponse = bundleResponse;
|
|
103
|
-
const extractSourceMap = (output) => {
|
|
104
|
-
const marker = '//# sourceMappingURL=data:application/json;base64,';
|
|
105
|
-
const startContent = output.indexOf(marker) + marker.length;
|
|
106
|
-
const sourceMapBase64Data = output.substring(startContent);
|
|
107
|
-
const sourceMapData = Buffer.from(sourceMapBase64Data, 'base64').toString('utf-8');
|
|
108
|
-
return sourceMapData;
|
|
109
|
-
};
|
|
110
|
-
const removeSourceMap = (output) => {
|
|
111
|
-
const marker = '//# sourceMappingURL=data:application/json;base64,';
|
|
112
|
-
const startContent = output.indexOf(marker);
|
|
113
|
-
const withoutSourceMap = output.substring(0, startContent);
|
|
114
|
-
return withoutSourceMap;
|
|
115
|
-
};
|
|
116
|
-
const sourceMapResponse = async ({ entryPoint, }) => {
|
|
117
|
-
const res = await (0, esbuild_1.build)({
|
|
118
|
-
...sharedConfig(false),
|
|
119
|
-
entryPoints: [entryPoint],
|
|
120
|
-
sourcemap: 'inline',
|
|
121
|
-
...getEsBuildConfig(entryPoint),
|
|
122
|
-
write: false,
|
|
123
|
-
});
|
|
124
|
-
const output = Buffer.from(res.outputFiles[0].contents).toString('utf-8');
|
|
125
|
-
const sourceMapData = extractSourceMap(output);
|
|
126
|
-
return {
|
|
127
|
-
statusCode: 201,
|
|
128
|
-
headers: {
|
|
129
|
-
'Content-Type': 'application/json',
|
|
130
|
-
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
131
|
-
Pragma: 'no-cache',
|
|
132
|
-
Expire: '0',
|
|
133
|
-
},
|
|
134
|
-
body: sourceMapData,
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
exports.sourceMapResponse = sourceMapResponse;
|
|
138
|
-
//# sourceMappingURL=compileBundle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compileBundle.js","sourceRoot":"","sources":["../../src/compileBundle.ts"],"names":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