@kaoruisaac/pedelec 0.4.1 → 0.4.3
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/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/vite.js +32 -14
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.4.
|
|
1
|
+
export declare const SDK_VERSION = "0.4.3";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated from sdk/package.json. Do not edit manually.
|
|
2
|
-
export const SDK_VERSION = "0.4.
|
|
2
|
+
export const SDK_VERSION = "0.4.3";
|
package/dist/vite.js
CHANGED
|
@@ -12,6 +12,7 @@ const DECLARATION_LIKE_EXTENSIONS = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs
|
|
|
12
12
|
const LEGACY_NODE_BUILTIN_MODULES = new Set(builtinModules.filter((specifier) => !specifier.startsWith("node:")));
|
|
13
13
|
const NODE_BUILTIN_MODULES = new Set(builtinModules.map((specifier) => specifier.replace(/^node:/, "")));
|
|
14
14
|
const nodeRequire = createRequire(import.meta.url);
|
|
15
|
+
const ssrResolvers = new WeakMap();
|
|
15
16
|
/**
|
|
16
17
|
* Vite build-time support for the static Deno module authoring API.
|
|
17
18
|
*
|
|
@@ -85,7 +86,7 @@ export function pedelecVitePlugin() {
|
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
async function prepareDeclaration(declaration, importer, resolveModule, config) {
|
|
88
|
-
const entry = await resolveEntry(declaration, importer, resolveModule);
|
|
89
|
+
const entry = await resolveEntry(declaration, importer, resolveModule, config);
|
|
89
90
|
const diagnosticPrefix = `Deno module "${declaration.name}" entry "${declaration.entry}" imported by "${importer}"`;
|
|
90
91
|
let runtimeBundle;
|
|
91
92
|
try {
|
|
@@ -119,13 +120,13 @@ async function prepareDeclaration(declaration, importer, resolveModule, config)
|
|
|
119
120
|
dependencies: new Set([...dependencies].map(normalizeFile)),
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
|
-
async function resolveEntry(declaration, importer, resolveModule) {
|
|
123
|
+
async function resolveEntry(declaration, importer, resolveModule, config) {
|
|
123
124
|
if (isRemoteOrSchemeEntry(declaration.entry)) {
|
|
124
125
|
throw new Error(`Deno module "${declaration.name}" entry "${declaration.entry}" is not a local or package specifier; remote and scheme URLs are not supported`);
|
|
125
126
|
}
|
|
126
127
|
let result;
|
|
127
128
|
try {
|
|
128
|
-
result = await resolveHostModule(declaration.entry, importer, resolveModule);
|
|
129
|
+
result = await resolveHostModule(declaration.entry, importer, resolveModule, config);
|
|
129
130
|
}
|
|
130
131
|
catch (error) {
|
|
131
132
|
throw new Error(`could not resolve entry "${declaration.entry}" for Deno module "${declaration.name}" from "${importer}": ${formatError(error)}`);
|
|
@@ -145,7 +146,7 @@ async function bundleRuntime(entry, resolveModule, config) {
|
|
|
145
146
|
return { id: builtin, external: true };
|
|
146
147
|
if (!importer || source.startsWith("\0"))
|
|
147
148
|
return null;
|
|
148
|
-
const resolved = await resolveHostModule(source, importer, resolveModule);
|
|
149
|
+
const resolved = await resolveHostModule(source, importer, resolveModule, config);
|
|
149
150
|
if (!resolved) {
|
|
150
151
|
throw new Error(`unresolved runtime dependency "${source}" from "${importer}"`);
|
|
151
152
|
}
|
|
@@ -167,6 +168,10 @@ async function bundleRuntime(entry, resolveModule, config) {
|
|
|
167
168
|
conditions: config?.resolve.conditions,
|
|
168
169
|
mainFields: config?.resolve.mainFields,
|
|
169
170
|
},
|
|
171
|
+
ssr: {
|
|
172
|
+
noExternal: true,
|
|
173
|
+
target: "node",
|
|
174
|
+
},
|
|
170
175
|
build: {
|
|
171
176
|
write: false,
|
|
172
177
|
emptyOutDir: false,
|
|
@@ -174,12 +179,8 @@ async function bundleRuntime(entry, resolveModule, config) {
|
|
|
174
179
|
target: "esnext",
|
|
175
180
|
sourcemap: false,
|
|
176
181
|
cssCodeSplit: false,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
formats: ["es"],
|
|
180
|
-
fileName: () => "index.mjs",
|
|
181
|
-
},
|
|
182
|
-
rollupOptions: {
|
|
182
|
+
ssr: true,
|
|
183
|
+
rolldownOptions: {
|
|
183
184
|
input: entry,
|
|
184
185
|
output: {
|
|
185
186
|
format: "es",
|
|
@@ -232,7 +233,7 @@ async function bundleRuntime(entry, resolveModule, config) {
|
|
|
232
233
|
}
|
|
233
234
|
return { source: entryChunk.code, files };
|
|
234
235
|
}
|
|
235
|
-
async function resolveHostModule(source, importer, resolveModule) {
|
|
236
|
+
async function resolveHostModule(source, importer, resolveModule, config) {
|
|
236
237
|
const resolved = await resolveModule(source, importer, { skipSelf: true });
|
|
237
238
|
const resolvedFile = resolved ? stripQueryAndHash(resolved.id) : null;
|
|
238
239
|
const needsPackageFallback = Boolean(isBareSpecifier(source) &&
|
|
@@ -240,6 +241,23 @@ async function resolveHostModule(source, importer, resolveModule) {
|
|
|
240
241
|
(isOptimizedDependencyPath(resolved.id) || resolved.external || !ts.sys.fileExists(resolvedFile)));
|
|
241
242
|
if (!needsPackageFallback)
|
|
242
243
|
return resolved;
|
|
244
|
+
if (config) {
|
|
245
|
+
try {
|
|
246
|
+
let resolver = ssrResolvers.get(config);
|
|
247
|
+
if (!resolver) {
|
|
248
|
+
resolver = config.createResolver();
|
|
249
|
+
ssrResolvers.set(config, resolver);
|
|
250
|
+
}
|
|
251
|
+
const serverResolved = await resolver(source, importer, false, true);
|
|
252
|
+
if (serverResolved)
|
|
253
|
+
return { id: serverResolved };
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
// Fall through to the legacy Node resolver. Custom Vite plugins can still
|
|
257
|
+
// return a usable outer resolution even when Vite's internal SSR resolver
|
|
258
|
+
// cannot resolve the specifier.
|
|
259
|
+
}
|
|
260
|
+
}
|
|
243
261
|
try {
|
|
244
262
|
return { id: nodeRequire.resolve(source, { paths: [dirname(importer)] }) };
|
|
245
263
|
}
|
|
@@ -298,7 +316,7 @@ async function bundleDeclarations(runtimeEntry, specifier, importer, diagnosticP
|
|
|
298
316
|
continue;
|
|
299
317
|
if (!canResolveDeclarationDependency(moduleSpecifier, packageBoundary))
|
|
300
318
|
continue;
|
|
301
|
-
const resolved = await resolveDeclarationDependency(moduleSpecifier, fileName, options, host, resolveModule);
|
|
319
|
+
const resolved = await resolveDeclarationDependency(moduleSpecifier, fileName, options, host, resolveModule, config);
|
|
302
320
|
if (!resolved) {
|
|
303
321
|
throw new Error(`${diagnosticPrefix}: public declaration still depends on unresolved module "${moduleSpecifier}"`);
|
|
304
322
|
}
|
|
@@ -481,12 +499,12 @@ function resolveExportTarget(target, packageDirectory) {
|
|
|
481
499
|
}
|
|
482
500
|
return null;
|
|
483
501
|
}
|
|
484
|
-
async function resolveDeclarationDependency(specifier, importer, options, host, resolveModule) {
|
|
502
|
+
async function resolveDeclarationDependency(specifier, importer, options, host, resolveModule, config) {
|
|
485
503
|
const fromTypeScript = ts.resolveModuleName(specifier, importer, options, host).resolvedModule?.resolvedFileName;
|
|
486
504
|
if (fromTypeScript && !isTypeScriptLib(fromTypeScript) && isDeclarationLikePath(fromTypeScript)) {
|
|
487
505
|
return normalizeFile(fromTypeScript);
|
|
488
506
|
}
|
|
489
|
-
const viteResolved = await resolveHostModule(specifier, importer, resolveModule);
|
|
507
|
+
const viteResolved = await resolveHostModule(specifier, importer, resolveModule, config);
|
|
490
508
|
if (!viteResolved || viteResolved.external)
|
|
491
509
|
return null;
|
|
492
510
|
const resolvedId = stripQueryAndHash(viteResolved.id);
|