Skip to content

Commit

Permalink
update route's import function
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Aug 6, 2023
1 parent ba888f1 commit 8027662
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 107 deletions.
10 changes: 5 additions & 5 deletions packages/vinxi/lib/build.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createRequire } from "module";
import { build, copyPublicAssets, createNitro } from "nitropack";
import { join } from "path";
import { relative } from "pathe";
Expand All @@ -10,6 +11,8 @@ import { manifest } from "./plugins/manifest.js";
import { routes } from "./plugins/routes.js";
import { treeShake } from "./plugins/tree-shake.js";

const require = createRequire(import.meta.url);

/**
*
* @param {import('./app.js').App} app
Expand Down Expand Up @@ -47,11 +50,8 @@ export async function createBuild(app, buildConfig) {
process.env.NITRO_PRESET ??
app.config.server.preset,
alias: {
"node-fetch-native/polyfill": fileURLToPath(
new URL(
"../node_modules/node-fetch-native/dist/polyfill.mjs",
import.meta.url,
),
"node-fetch-native/polyfill": require.resolve(
"node-fetch-native/polyfill",
),
},
// externals: {
Expand Down
7 changes: 3 additions & 4 deletions packages/vinxi/lib/plugins/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ export function routes() {
return {
src: isBuild ? relative(root, buildId) : buildId,
build: isBuild ? `_$() => import('${buildId}')$_` : undefined,
import: isBuild
? router.build.target === "node"
import:
router.build.target === "node"
? `_$() => import('${buildId}')$_`
: `_$(() => { const id = '${relative(
root,
buildId,
)}'; return import(import.meta.env.MANIFEST['${
router.name
}'].inputs[id].output.path) })$_`
: undefined,
}'].inputs[id].output.path) })$_`,
};
}
return v;
Expand Down
6 changes: 3 additions & 3 deletions packages/vinxi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vinxi",
"version": "0.0.8",
"version": "0.0.12",
"type": "module",
"author": "Nikhil Saraf <nsaraf98@gmail.com>",
"files": [
Expand Down Expand Up @@ -49,12 +49,12 @@
"es-module-lexer": "^1.3.0",
"esbuild": "^0.18.14",
"fast-glob": "^3.3.0",
"h3": "^1.8.0-rc.1",
"h3": "1.8.0-rc.2",
"http-proxy": "^1.18.1",
"listhen": "^1.0.4",
"micromatch": "^4.0.5",
"mri": "^1.2.0",
"nitropack": "npm:nitropack-edge@2.6.0-28180270.6217581",
"nitropack": "npm:nitropack-edge@2.6.0-28186311.f8d176b",
"node-fetch-native": "^1.2.0",
"path-to-regexp": "^6.2.1",
"pathe": "^1.1.1",
Expand Down
Loading

0 comments on commit 8027662

Please sign in to comment.