@chuckcchen/vite-plugin 0.0.2 → 0.0.4
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/bundler.d.ts +27 -27
- package/dist/bundler.js +89 -89
- package/dist/bundler.js.map +1 -1
- package/dist/core.d.ts +14 -14
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +179 -150
- package/dist/core.js.map +1 -1
- package/dist/factory.d.ts +124 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +264 -0
- package/dist/factory.js.map +1 -0
- package/dist/helpers.d.ts +40 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +166 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +8 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -56
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +113 -113
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/dist/utils.d.ts +56 -56
- package/dist/utils.js +68 -68
- package/dist/utils.js.map +1 -1
- package/package.json +2 -1
package/dist/bundler.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EdgeOne Vite Plugin Adapter -
|
|
2
|
+
* EdgeOne Vite Plugin Adapter - Server Bundling Module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
4
|
+
* This module handles server-side code bundling using esbuild, main features include:
|
|
5
|
+
* - Bundle framework's server build artifacts into a single file
|
|
6
|
+
* - Generate HTTP request handling wrapper code
|
|
7
|
+
* - Handle Node.js request to Web API Request conversion
|
|
8
8
|
*/
|
|
9
9
|
import * as esbuild from "esbuild";
|
|
10
10
|
import type { BuildContext, ServerBundleConfig, ServerWrapperConfig } from "./types.js";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Bundle server code using esbuild
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Bundle server entry file and all dependencies into a single JavaScript file
|
|
15
|
+
* for running in EdgeOne edge function environment
|
|
16
16
|
*
|
|
17
|
-
* @param context -
|
|
18
|
-
* @param config -
|
|
19
|
-
* @returns esbuild
|
|
17
|
+
* @param context - Build context containing project root and logger
|
|
18
|
+
* @param config - Bundle configuration including entry points, output path, etc.
|
|
19
|
+
* @returns esbuild build result containing metadata info
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* await bundleServerCode(context, {
|
|
@@ -26,17 +26,17 @@ import type { BuildContext, ServerBundleConfig, ServerWrapperConfig } from "./ty
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function bundleServerCode(context: BuildContext, config: ServerBundleConfig): Promise<esbuild.BuildResult>;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Create server wrapper file
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* 1.
|
|
34
|
-
* 2.
|
|
35
|
-
* 3.
|
|
31
|
+
* Wrap framework's server build artifacts into a unified HTTP request handler.
|
|
32
|
+
* The wrapper is responsible for:
|
|
33
|
+
* 1. Converting Node.js IncomingMessage to Web API Request object
|
|
34
|
+
* 2. Calling framework's request handler function
|
|
35
|
+
* 3. Exporting unified request handling interface
|
|
36
36
|
*
|
|
37
|
-
* @param context -
|
|
38
|
-
* @param config -
|
|
39
|
-
* @returns
|
|
37
|
+
* @param context - Build context
|
|
38
|
+
* @param config - Wrapper configuration
|
|
39
|
+
* @returns Path to generated temporary wrapper file
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
42
|
* const wrapperPath = await createServerWrapper(context, {
|
|
@@ -45,22 +45,22 @@ export declare function bundleServerCode(context: BuildContext, config: ServerBu
|
|
|
45
45
|
*/
|
|
46
46
|
export declare function createServerWrapper(context: BuildContext, config: ServerWrapperConfig): Promise<string>;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
48
|
+
* Cleanup temporary wrapper file
|
|
49
|
+
* Delete temporarily generated wrapper file after bundling completes
|
|
50
50
|
*
|
|
51
|
-
* @param wrapperPath -
|
|
51
|
+
* @param wrapperPath - Wrapper file path
|
|
52
52
|
*/
|
|
53
53
|
export declare function cleanupWrapper(wrapperPath: string): Promise<void>;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* Get bundle result file size
|
|
56
56
|
*
|
|
57
|
-
* @param result - esbuild
|
|
58
|
-
* @returns
|
|
57
|
+
* @param result - esbuild build result
|
|
58
|
+
* @returns Bundled file size in bytes, returns 0 if unavailable
|
|
59
59
|
*
|
|
60
60
|
* @example
|
|
61
61
|
* const result = await bundleServerCode(context, config);
|
|
62
62
|
* const size = getBundleSize(result);
|
|
63
|
-
* console.log(
|
|
63
|
+
* console.log(`Bundle size: ${formatSize(size)}`);
|
|
64
64
|
*/
|
|
65
65
|
export declare function getBundleSize(result: esbuild.BuildResult): number;
|
|
66
66
|
//# sourceMappingURL=bundler.d.ts.map
|
package/dist/bundler.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EdgeOne Vite Plugin Adapter -
|
|
2
|
+
* EdgeOne Vite Plugin Adapter - Server Bundling Module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
4
|
+
* This module handles server-side code bundling using esbuild, main features include:
|
|
5
|
+
* - Bundle framework's server build artifacts into a single file
|
|
6
|
+
* - Generate HTTP request handling wrapper code
|
|
7
|
+
* - Handle Node.js request to Web API Request conversion
|
|
8
8
|
*/
|
|
9
9
|
import * as esbuild from "esbuild";
|
|
10
10
|
import path from "path";
|
|
11
11
|
import { readFile, writeFile, deleteFile, ensureDirectory } from "./utils.js";
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Default ESM compatibility banner code
|
|
14
|
+
* Provides CommonJS require, __filename, __dirname support in ESM modules
|
|
15
|
+
* This is because some dependencies may still use CommonJS syntax
|
|
16
16
|
*/
|
|
17
17
|
const DEFAULT_BANNER = `import { createRequire } from 'node:module';
|
|
18
18
|
const require = createRequire(import.meta.url);
|
|
19
19
|
const __filename = new URL('', import.meta.url).pathname;
|
|
20
20
|
const __dirname = new URL('.', import.meta.url).pathname;`;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Bundle server code using esbuild
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* Bundle server entry file and all dependencies into a single JavaScript file
|
|
25
|
+
* for running in EdgeOne edge function environment
|
|
26
26
|
*
|
|
27
|
-
* @param context -
|
|
28
|
-
* @param config -
|
|
29
|
-
* @returns esbuild
|
|
27
|
+
* @param context - Build context containing project root and logger
|
|
28
|
+
* @param config - Bundle configuration including entry points, output path, etc.
|
|
29
|
+
* @returns esbuild build result containing metadata info
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
32
|
* await bundleServerCode(context, {
|
|
@@ -36,43 +36,43 @@ const __dirname = new URL('.', import.meta.url).pathname;`;
|
|
|
36
36
|
*/
|
|
37
37
|
export async function bundleServerCode(context, config) {
|
|
38
38
|
const { projectRoot, logger } = context;
|
|
39
|
-
logger.verbose("
|
|
40
|
-
//
|
|
39
|
+
logger.verbose("Bundling server code...");
|
|
40
|
+
// Ensure output directory exists
|
|
41
41
|
await ensureDirectory(path.dirname(config.outfile));
|
|
42
|
-
//
|
|
42
|
+
// Bundle using esbuild
|
|
43
43
|
const result = await esbuild.build({
|
|
44
|
-
entryPoints: config.entryPoints, //
|
|
45
|
-
bundle: true, //
|
|
46
|
-
platform: "node", //
|
|
47
|
-
target: "node18", //
|
|
48
|
-
format: "esm", //
|
|
49
|
-
outfile: config.outfile, //
|
|
50
|
-
minify: false, //
|
|
51
|
-
treeShaking: true, //
|
|
52
|
-
external: ["node:*", ...(config.external || [])], //
|
|
53
|
-
metafile: true, //
|
|
54
|
-
logLevel: "warning", //
|
|
55
|
-
absWorkingDir: projectRoot, //
|
|
44
|
+
entryPoints: config.entryPoints, // Entry file list
|
|
45
|
+
bundle: true, // Enable bundling, pack all dependencies together
|
|
46
|
+
platform: "node", // Target platform is Node.js
|
|
47
|
+
target: "node18", // Target Node.js version
|
|
48
|
+
format: "esm", // Output format is ESM
|
|
49
|
+
outfile: config.outfile, // Output file path
|
|
50
|
+
minify: false, // Don't minify for easier debugging
|
|
51
|
+
treeShaking: true, // Enable tree shaking to remove unused code
|
|
52
|
+
external: ["node:*", ...(config.external || [])], // Exclude Node.js built-in modules
|
|
53
|
+
metafile: true, // Generate metafile for bundle analysis
|
|
54
|
+
logLevel: "warning", // Log level
|
|
55
|
+
absWorkingDir: projectRoot, // Working directory
|
|
56
56
|
banner: {
|
|
57
|
-
js: DEFAULT_BANNER, //
|
|
57
|
+
js: DEFAULT_BANNER, // Add ESM compatibility banner
|
|
58
58
|
},
|
|
59
|
-
...config.esbuildOptions, //
|
|
59
|
+
...config.esbuildOptions, // Merge additional esbuild options
|
|
60
60
|
});
|
|
61
|
-
logger.verbose(
|
|
61
|
+
logger.verbose(`Server code bundled to: ${config.outfile}`);
|
|
62
62
|
return result;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Create server wrapper file
|
|
66
66
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* 1.
|
|
70
|
-
* 2.
|
|
71
|
-
* 3.
|
|
67
|
+
* Wrap framework's server build artifacts into a unified HTTP request handler.
|
|
68
|
+
* The wrapper is responsible for:
|
|
69
|
+
* 1. Converting Node.js IncomingMessage to Web API Request object
|
|
70
|
+
* 2. Calling framework's request handler function
|
|
71
|
+
* 3. Exporting unified request handling interface
|
|
72
72
|
*
|
|
73
|
-
* @param context -
|
|
74
|
-
* @param config -
|
|
75
|
-
* @returns
|
|
73
|
+
* @param context - Build context
|
|
74
|
+
* @param config - Wrapper configuration
|
|
75
|
+
* @returns Path to generated temporary wrapper file
|
|
76
76
|
*
|
|
77
77
|
* @example
|
|
78
78
|
* const wrapperPath = await createServerWrapper(context, {
|
|
@@ -81,88 +81,88 @@ export async function bundleServerCode(context, config) {
|
|
|
81
81
|
*/
|
|
82
82
|
export async function createServerWrapper(context, config) {
|
|
83
83
|
const { projectRoot, logger } = context;
|
|
84
|
-
logger.verbose("
|
|
85
|
-
//
|
|
84
|
+
logger.verbose("Creating server wrapper...");
|
|
85
|
+
// Read original server build content
|
|
86
86
|
const serverBuildContent = await readFile(config.serverEntryPath);
|
|
87
|
-
//
|
|
87
|
+
// Generate wrapper content
|
|
88
88
|
let wrapperContent;
|
|
89
89
|
if (config.wrapperTemplate) {
|
|
90
|
-
//
|
|
90
|
+
// Use custom template, replace placeholders
|
|
91
91
|
wrapperContent = config.wrapperTemplate.replace("{{SERVER_BUILD_CONTENT}}", serverBuildContent);
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
|
-
//
|
|
94
|
+
// Use default wrapper template
|
|
95
95
|
wrapperContent = generateDefaultWrapper(serverBuildContent, config);
|
|
96
96
|
}
|
|
97
|
-
//
|
|
97
|
+
// Write to temporary file
|
|
98
98
|
const tempPath = path.join(projectRoot, "server-wrapper.temp.js");
|
|
99
99
|
await writeFile(tempPath, wrapperContent);
|
|
100
|
-
logger.verbose("
|
|
100
|
+
logger.verbose("Server wrapper created");
|
|
101
101
|
return tempPath;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
104
|
+
* Cleanup temporary wrapper file
|
|
105
|
+
* Delete temporarily generated wrapper file after bundling completes
|
|
106
106
|
*
|
|
107
|
-
* @param wrapperPath -
|
|
107
|
+
* @param wrapperPath - Wrapper file path
|
|
108
108
|
*/
|
|
109
109
|
export async function cleanupWrapper(wrapperPath) {
|
|
110
110
|
try {
|
|
111
111
|
await deleteFile(wrapperPath);
|
|
112
112
|
}
|
|
113
113
|
catch {
|
|
114
|
-
//
|
|
114
|
+
// Ignore delete errors (file may not exist)
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
*
|
|
118
|
+
* Generate default server wrapper code
|
|
119
119
|
*
|
|
120
|
-
*
|
|
121
|
-
* 1.
|
|
122
|
-
* 2. Node.js
|
|
123
|
-
* 3.
|
|
120
|
+
* Wrapper code contains:
|
|
121
|
+
* 1. Original server build content
|
|
122
|
+
* 2. Node.js request to Web Request conversion function
|
|
123
|
+
* 3. Unified request handler export
|
|
124
124
|
*
|
|
125
|
-
* @param serverBuildContent -
|
|
126
|
-
* @param config -
|
|
127
|
-
* @returns
|
|
125
|
+
* @param serverBuildContent - Original server build code content
|
|
126
|
+
* @param config - Wrapper configuration
|
|
127
|
+
* @returns Generated wrapper code string
|
|
128
128
|
*/
|
|
129
129
|
function generateDefaultWrapper(serverBuildContent, config) {
|
|
130
130
|
const banner = config.banner || "";
|
|
131
131
|
const exports = config.exports || [];
|
|
132
|
-
//
|
|
132
|
+
// Build export statement
|
|
133
133
|
const exportsStr = exports.length > 0
|
|
134
134
|
? exports.join(", ")
|
|
135
135
|
: "default as handler";
|
|
136
|
-
return `// ==========
|
|
136
|
+
return `// ========== Server Build Content ==========
|
|
137
137
|
${serverBuildContent}
|
|
138
138
|
|
|
139
|
-
// ========== HTTP
|
|
139
|
+
// ========== HTTP Server Wrapper ==========
|
|
140
140
|
${banner}
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
143
|
+
* Convert Node.js IncomingMessage to Web API Request
|
|
144
144
|
*
|
|
145
|
-
* EdgeOne
|
|
146
|
-
*
|
|
147
|
-
*
|
|
145
|
+
* EdgeOne edge functions use Web API standard Request/Response,
|
|
146
|
+
* but some framework server builds may expect Node.js style request objects.
|
|
147
|
+
* This function handles the conversion.
|
|
148
148
|
*
|
|
149
|
-
* @param nodeReq - Node.js
|
|
150
|
-
* @returns Web API
|
|
149
|
+
* @param nodeReq - Node.js IncomingMessage object
|
|
150
|
+
* @returns Web API Request object
|
|
151
151
|
*/
|
|
152
152
|
function nodeRequestToWebRequest(nodeReq) {
|
|
153
|
-
//
|
|
154
|
-
//
|
|
153
|
+
// Build complete URL
|
|
154
|
+
// Determine protocol based on whether connection is encrypted
|
|
155
155
|
const protocol = nodeReq.connection?.encrypted ? 'https' : 'http';
|
|
156
156
|
const host = nodeReq.headers.host || 'localhost';
|
|
157
157
|
const url = \`\${protocol}://\${host}\${nodeReq.url}\`;
|
|
158
158
|
|
|
159
|
-
//
|
|
160
|
-
// Node.js
|
|
159
|
+
// Convert request headers
|
|
160
|
+
// Node.js headers are plain objects, need to convert to Headers instance
|
|
161
161
|
const headers = new Headers();
|
|
162
162
|
for (const [key, value] of Object.entries(nodeReq.headers)) {
|
|
163
163
|
if (value) {
|
|
164
164
|
if (Array.isArray(value)) {
|
|
165
|
-
//
|
|
165
|
+
// Multi-value headers (like Set-Cookie) need multiple appends
|
|
166
166
|
value.forEach(v => headers.append(key, v));
|
|
167
167
|
} else {
|
|
168
168
|
headers.set(key, value);
|
|
@@ -170,14 +170,14 @@ function nodeRequestToWebRequest(nodeReq) {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
//
|
|
173
|
+
// Build Request init options
|
|
174
174
|
const init = {
|
|
175
175
|
method: nodeReq.method,
|
|
176
176
|
headers: headers,
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
-
//
|
|
180
|
-
// GET
|
|
179
|
+
// Add request body for non-GET/HEAD requests
|
|
180
|
+
// GET and HEAD requests should not have body
|
|
181
181
|
if (nodeReq.method !== 'GET' && nodeReq.method !== 'HEAD') {
|
|
182
182
|
init.body = nodeReq;
|
|
183
183
|
}
|
|
@@ -186,14 +186,14 @@ function nodeRequestToWebRequest(nodeReq) {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
|
-
* Node.js
|
|
189
|
+
* Node.js request handler wrapper function
|
|
190
190
|
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
191
|
+
* This is the main entry exported for EdgeOne edge functions to call.
|
|
192
|
+
* Responsible for converting Node.js request before passing to framework handler.
|
|
193
193
|
*
|
|
194
|
-
* @param nodeReq - Node.js
|
|
195
|
-
* @param args -
|
|
196
|
-
* @returns
|
|
194
|
+
* @param nodeReq - Node.js request object
|
|
195
|
+
* @param args - Other arguments (e.g. env variables, context, etc.)
|
|
196
|
+
* @returns Framework handler return value (usually Response object)
|
|
197
197
|
*/
|
|
198
198
|
async function nodeRequestHandler(nodeReq, ...args) {
|
|
199
199
|
const webRequest = nodeRequestToWebRequest(nodeReq);
|
|
@@ -205,25 +205,25 @@ export { ${exportsStr} };
|
|
|
205
205
|
`;
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
208
|
-
*
|
|
208
|
+
* Get bundle result file size
|
|
209
209
|
*
|
|
210
|
-
* @param result - esbuild
|
|
211
|
-
* @returns
|
|
210
|
+
* @param result - esbuild build result
|
|
211
|
+
* @returns Bundled file size in bytes, returns 0 if unavailable
|
|
212
212
|
*
|
|
213
213
|
* @example
|
|
214
214
|
* const result = await bundleServerCode(context, config);
|
|
215
215
|
* const size = getBundleSize(result);
|
|
216
|
-
* console.log(
|
|
216
|
+
* console.log(`Bundle size: ${formatSize(size)}`);
|
|
217
217
|
*/
|
|
218
218
|
export function getBundleSize(result) {
|
|
219
|
-
//
|
|
219
|
+
// Need metafile to get size info
|
|
220
220
|
if (!result.metafile)
|
|
221
221
|
return 0;
|
|
222
222
|
const outputs = result.metafile.outputs;
|
|
223
223
|
const outputKeys = Object.keys(outputs);
|
|
224
224
|
if (outputKeys.length === 0)
|
|
225
225
|
return 0;
|
|
226
|
-
//
|
|
226
|
+
// Return size of first output file
|
|
227
227
|
return outputs[outputKeys[0]].bytes;
|
|
228
228
|
}
|
|
229
229
|
//# sourceMappingURL=bundler.js.map
|
package/dist/bundler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../src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AAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAExC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAEtC,mCAAmC;IACnC,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACtC,CAAC"}
|
package/dist/core.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EdgeOne Vite Plugin Adapter -
|
|
2
|
+
* EdgeOne Vite Plugin Adapter - Core Plugin Module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
9
|
-
* - Meta.json
|
|
4
|
+
* This module is the core of the adapter system, responsible for:
|
|
5
|
+
* - Build artifacts detection: Auto-detect client and server build outputs
|
|
6
|
+
* - Static assets copying: Copy client build artifacts to deployment directory
|
|
7
|
+
* - Server code bundling: Bundle server code into a single file
|
|
8
|
+
* - Route config generation: Generate route info based on framework features
|
|
9
|
+
* - Meta.json generation: Generate configuration file for EdgeOne deployment
|
|
10
10
|
*/
|
|
11
11
|
import type { Plugin } from "vite";
|
|
12
12
|
import type { CoreAdapterOptions } from "./types.js";
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Create EdgeOne core adapter plugin
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* This is the main entry function for creating adapters, returns a Vite plugin instance.
|
|
17
|
+
* The plugin executes after Vite build completes, processing build artifacts and generating deployment config.
|
|
18
18
|
*
|
|
19
|
-
* @param options -
|
|
20
|
-
* @returns Vite
|
|
19
|
+
* @param options - Adapter configuration options
|
|
20
|
+
* @returns Vite plugin instance
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
|
-
* //
|
|
23
|
+
* // Basic usage
|
|
24
24
|
* createCoreAdapter({ verbose: true })
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
|
-
* //
|
|
27
|
+
* // Using framework adapter
|
|
28
28
|
* createCoreAdapter({
|
|
29
29
|
* adapter: myFrameworkAdapter,
|
|
30
30
|
* outputDir: '.edgeone'
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAEnD,OAAO,KAAK,EACV,kBAAkB,EAOnB,MAAM,YAAY,CAAC;AAepB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAEnD,OAAO,KAAK,EACV,kBAAkB,EAOnB,MAAM,YAAY,CAAC;AAepB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,MAAM,CAiJ1E;AAgTD,eAAe,iBAAiB,CAAC"}
|