@squadbase/vite-server 0.1.18 → 0.1.19

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/index.js CHANGED
@@ -47691,8 +47691,14 @@ function getSkippedServerLogics() {
47691
47691
  }
47692
47692
  var viteServer = null;
47693
47693
  function validateHandlerPath(dirPath, handlerPath) {
47694
- const absolute = path2.resolve(dirPath, handlerPath);
47695
47694
  const normalizedDir = path2.resolve(dirPath);
47695
+ const dirBase = path2.basename(normalizedDir);
47696
+ let normalized = handlerPath.replace(/^\.?[/\\]/, "");
47697
+ const prefix = dirBase + "/";
47698
+ if (normalized.startsWith(prefix)) {
47699
+ normalized = normalized.slice(prefix.length);
47700
+ }
47701
+ const absolute = path2.resolve(dirPath, normalized);
47696
47702
  if (!absolute.startsWith(normalizedDir + path2.sep)) {
47697
47703
  throw new Error(`Handler path escapes server-logic directory: ${handlerPath}`);
47698
47704
  }
@@ -47701,6 +47707,19 @@ function validateHandlerPath(dirPath, handlerPath) {
47701
47707
  }
47702
47708
  return absolute;
47703
47709
  }
47710
+ var jitiInstance = null;
47711
+ var jitiModuleCache = /* @__PURE__ */ new Map();
47712
+ async function loadTsHandlerWithJiti(absolutePath) {
47713
+ const cached = jitiModuleCache.get(absolutePath);
47714
+ if (cached) return cached;
47715
+ if (!jitiInstance) {
47716
+ const { createJiti } = await import("jiti");
47717
+ jitiInstance = createJiti(import.meta.url, { fsCache: false });
47718
+ }
47719
+ const mod = await jitiInstance.import(absolutePath);
47720
+ jitiModuleCache.set(absolutePath, mod);
47721
+ return mod;
47722
+ }
47704
47723
  async function loadTypeScriptHandler(absolutePath) {
47705
47724
  let mod;
47706
47725
  if (viteServer) {
@@ -47708,8 +47727,7 @@ async function loadTypeScriptHandler(absolutePath) {
47708
47727
  if (module) viteServer.moduleGraph.invalidateModule(module);
47709
47728
  mod = await viteServer.ssrLoadModule(absolutePath);
47710
47729
  } else {
47711
- const { pathToFileURL } = await import("url");
47712
- mod = await import(pathToFileURL(absolutePath).href);
47730
+ mod = await loadTsHandlerWithJiti(absolutePath);
47713
47731
  }
47714
47732
  const handler = mod.default;
47715
47733
  if (typeof handler !== "function") {
package/dist/main.js CHANGED
@@ -47424,8 +47424,14 @@ function getSkippedServerLogics() {
47424
47424
  }
47425
47425
  var viteServer = null;
47426
47426
  function validateHandlerPath(dirPath, handlerPath) {
47427
- const absolute = path2.resolve(dirPath, handlerPath);
47428
47427
  const normalizedDir = path2.resolve(dirPath);
47428
+ const dirBase = path2.basename(normalizedDir);
47429
+ let normalized = handlerPath.replace(/^\.?[/\\]/, "");
47430
+ const prefix = dirBase + "/";
47431
+ if (normalized.startsWith(prefix)) {
47432
+ normalized = normalized.slice(prefix.length);
47433
+ }
47434
+ const absolute = path2.resolve(dirPath, normalized);
47429
47435
  if (!absolute.startsWith(normalizedDir + path2.sep)) {
47430
47436
  throw new Error(`Handler path escapes server-logic directory: ${handlerPath}`);
47431
47437
  }
@@ -47434,6 +47440,19 @@ function validateHandlerPath(dirPath, handlerPath) {
47434
47440
  }
47435
47441
  return absolute;
47436
47442
  }
47443
+ var jitiInstance = null;
47444
+ var jitiModuleCache = /* @__PURE__ */ new Map();
47445
+ async function loadTsHandlerWithJiti(absolutePath) {
47446
+ const cached = jitiModuleCache.get(absolutePath);
47447
+ if (cached) return cached;
47448
+ if (!jitiInstance) {
47449
+ const { createJiti } = await import("jiti");
47450
+ jitiInstance = createJiti(import.meta.url, { fsCache: false });
47451
+ }
47452
+ const mod = await jitiInstance.import(absolutePath);
47453
+ jitiModuleCache.set(absolutePath, mod);
47454
+ return mod;
47455
+ }
47437
47456
  async function loadTypeScriptHandler(absolutePath) {
47438
47457
  let mod;
47439
47458
  if (viteServer) {
@@ -47441,8 +47460,7 @@ async function loadTypeScriptHandler(absolutePath) {
47441
47460
  if (module) viteServer.moduleGraph.invalidateModule(module);
47442
47461
  mod = await viteServer.ssrLoadModule(absolutePath);
47443
47462
  } else {
47444
- const { pathToFileURL } = await import("url");
47445
- mod = await import(pathToFileURL(absolutePath).href);
47463
+ mod = await loadTsHandlerWithJiti(absolutePath);
47446
47464
  }
47447
47465
  const handler = mod.default;
47448
47466
  if (typeof handler !== "function") {
@@ -47460,7 +47460,10 @@ function squadbasePlugin(options = {}) {
47460
47460
  "@aws-sdk/client-cost-explorer",
47461
47461
  "@aws-sdk/client-redshift-data",
47462
47462
  "@google-analytics/data",
47463
- "@kintone/rest-api-client"
47463
+ "@kintone/rest-api-client",
47464
+ // jiti はランタイムで server-logic/*.ts をトランスパイルするため、
47465
+ // @hono/vite-build がサーバービルドにバンドルしないよう external にする。
47466
+ "jiti"
47464
47467
  ],
47465
47468
  exclude = DEFAULT_EXCLUDE
47466
47469
  } = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squadbase/vite-server",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -359,6 +359,7 @@
359
359
  "@kintone/rest-api-client": "^5.5.0",
360
360
  "google-auth-library": "^9.15.1",
361
361
  "hono": "^4.12.25",
362
+ "jiti": "^2.7.0",
362
363
  "mongodb": "^7.1.1",
363
364
  "mssql": "^11.0.1",
364
365
  "mysql2": "^3.11.0",