@stacksjs/stx 0.2.144 → 0.2.145

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.
@@ -510,7 +510,7 @@ export function isCompleteImport(statement) {
510
510
  return quote === null && braces === 0 && closedSpecifier;
511
511
  }
512
512
  export function convertToCommonJS(scriptContent, filePath) {
513
- const templateDir = filePath ? path.dirname(filePath) : process.cwd(), lines = scriptContent.split(`
513
+ const templateDir = filePath ? path.dirname(filePath) : process.cwd(), projectRoot = process.cwd(), lines = scriptContent.split(`
514
514
  `), convertedLines = [];
515
515
  let i = 0;
516
516
  while (i < lines.length) {
@@ -581,6 +581,8 @@ export function convertToCommonJS(scriptContent, filePath) {
581
581
  const defaultImportMatch = statement.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/), namedImportMatch = statement.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/), sideEffectMatch = statement.match(/^import\s+['"](.+?)['"]/), line_ = statement, resolveSource = (source) => {
582
582
  if (source.startsWith("."))
583
583
  return path.resolve(templateDir, source);
584
+ if (source.startsWith("~/") || source.startsWith("@/"))
585
+ return path.resolve(projectRoot, source.slice(2));
584
586
  return source;
585
587
  };
586
588
  if (defaultImportMatch) {
@@ -673,9 +675,9 @@ export function convertToCommonJS(scriptContent, filePath) {
673
675
  i++;
674
676
  }
675
677
  return resolveDynamicImports(convertedLines.join(`
676
- `), templateDir);
678
+ `), templateDir, projectRoot);
677
679
  }
678
- function resolveDynamicImports(source, templateDir) {
680
+ function resolveDynamicImports(source, templateDir, projectRoot) {
679
681
  const len = source.length;
680
682
  let out = "", i = 0, inString = null, inLineComment = !1, inBlockComment = !1, inTemplateExpr = 0;
681
683
  while (i < len) {
@@ -755,8 +757,8 @@ function resolveDynamicImports(source, templateDir) {
755
757
  const match = matchDynamicImportAt(source, i);
756
758
  if (match) {
757
759
  const { quote, path: importPath, end } = match;
758
- if (importPath.startsWith(".")) {
759
- const resolved = path.resolve(templateDir, importPath);
760
+ if (importPath.startsWith(".") || importPath.startsWith("~/") || importPath.startsWith("@/")) {
761
+ const resolved = importPath.startsWith(".") ? path.resolve(templateDir, importPath) : path.resolve(projectRoot, importPath.slice(2));
760
762
  out += `await import(${quote}${resolved}${quote})`;
761
763
  i = end;
762
764
  continue;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.144",
4
+ "version": "0.2.145",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.14",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.144",
121
- "@stacksjs/sanitizer": "0.2.144",
120
+ "@stacksjs/desktop": "0.2.145",
121
+ "@stacksjs/sanitizer": "0.2.145",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.144",
123
+ "bun-plugin-stx": "0.2.145",
124
124
  "bunfig": "^0.15.15",
125
- "stx-router": "0.2.144",
125
+ "stx-router": "0.2.145",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.1.9",
128
128
  "ts-syntax-highlighter": "^0.2.1"