@lolyjs/core 0.2.0-alpha.20 → 0.2.0-alpha.21

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/cli.cjs CHANGED
@@ -13743,6 +13743,68 @@ function validateRealtimeConfig(config) {
13743
13743
  // modules/build/bundler/server.ts
13744
13744
  init_globals();
13745
13745
  var SERVER_FILES = [INIT_FILE_NAME, CONFIG_FILE_NAME];
13746
+ function createPathAliasPlugin(projectRoot, outDir) {
13747
+ const aliases = loadAliasesFromTsconfig(projectRoot);
13748
+ const tsconfigPath = import_path25.default.join(projectRoot, "tsconfig.json");
13749
+ let baseUrl = ".";
13750
+ if (import_fs16.default.existsSync(tsconfigPath)) {
13751
+ try {
13752
+ const tsconfig = JSON.parse(import_fs16.default.readFileSync(tsconfigPath, "utf-8"));
13753
+ baseUrl = tsconfig.compilerOptions?.baseUrl ?? ".";
13754
+ } catch {
13755
+ }
13756
+ }
13757
+ return {
13758
+ name: "path-alias-resolver",
13759
+ setup(build) {
13760
+ build.onResolve({ filter: /.*/ }, (args) => {
13761
+ if (args.path.startsWith(".") || args.path.startsWith("/") || import_path25.default.isAbsolute(args.path) || args.path.includes("node_modules")) {
13762
+ return null;
13763
+ }
13764
+ for (const [aliasKey, aliasPath] of Object.entries(aliases)) {
13765
+ if (args.path.startsWith(aliasKey + "/") || args.path === aliasKey) {
13766
+ const restPath = args.path.startsWith(aliasKey + "/") ? args.path.slice(aliasKey.length + 1) : "";
13767
+ const resolvedPath = restPath ? import_path25.default.join(aliasPath, restPath) : aliasPath;
13768
+ let actualPath = null;
13769
+ const extensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
13770
+ if (import_fs16.default.existsSync(resolvedPath) && import_fs16.default.statSync(resolvedPath).isDirectory()) {
13771
+ for (const ext of extensions) {
13772
+ const indexPath = import_path25.default.join(resolvedPath, `index${ext}`);
13773
+ if (import_fs16.default.existsSync(indexPath)) {
13774
+ actualPath = indexPath;
13775
+ break;
13776
+ }
13777
+ }
13778
+ } else {
13779
+ for (const ext of extensions) {
13780
+ const filePath = resolvedPath + ext;
13781
+ if (import_fs16.default.existsSync(filePath)) {
13782
+ actualPath = filePath;
13783
+ break;
13784
+ }
13785
+ }
13786
+ if (!actualPath && import_fs16.default.existsSync(resolvedPath)) {
13787
+ actualPath = resolvedPath;
13788
+ }
13789
+ }
13790
+ if (actualPath) {
13791
+ const relativePath = import_path25.default.relative(outDir, actualPath);
13792
+ const normalizedPath = relativePath.replace(/\\/g, "/");
13793
+ const finalPath = normalizedPath.startsWith(".") ? normalizedPath : `./${normalizedPath}`;
13794
+ const ext = import_path25.default.extname(finalPath);
13795
+ const pathWithoutExt = ext === ".json" ? finalPath : finalPath.slice(0, -ext.length);
13796
+ return {
13797
+ path: pathWithoutExt,
13798
+ namespace: "file"
13799
+ };
13800
+ }
13801
+ }
13802
+ }
13803
+ return null;
13804
+ });
13805
+ }
13806
+ };
13807
+ }
13746
13808
  function collectAppSources(appDir) {
13747
13809
  const entries = [];
13748
13810
  function walk(dir) {
@@ -13786,6 +13848,7 @@ async function buildServerApp(projectRoot, appDir) {
13786
13848
  tsconfig: import_path25.default.join(projectRoot, "tsconfig.json"),
13787
13849
  packages: "external"
13788
13850
  });
13851
+ const pathAliasPlugin = createPathAliasPlugin(projectRoot, outDir);
13789
13852
  for (const fileName of SERVER_FILES) {
13790
13853
  const initTS = import_path25.default.join(projectRoot, `${fileName}.ts`);
13791
13854
  const initJS = import_path25.default.join(outDir, `${fileName}.js`);
@@ -13800,7 +13863,8 @@ async function buildServerApp(projectRoot, appDir) {
13800
13863
  sourcemap: true,
13801
13864
  bundle: false,
13802
13865
  logLevel: "info",
13803
- tsconfig: import_path25.default.join(projectRoot, "tsconfig.json")
13866
+ tsconfig: import_path25.default.join(projectRoot, "tsconfig.json"),
13867
+ plugins: [pathAliasPlugin]
13804
13868
  });
13805
13869
  }
13806
13870
  }