@slim-lang/core 1.2.3 → 1.2.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/modulePaths.js +17 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slim-lang/core",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Slim extends JavaScript with runtime types, structs, operators, and components, compiling to plain Javascript",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -49,9 +49,23 @@ export function getDistPath(slimFile) {
49
49
  const abs = path.resolve(slimFile)
50
50
  const srcRoot = path.resolve("src")
51
51
  const projectRoot = path.resolve(".")
52
- const relative = isWithin(srcRoot, abs)
53
- ? path.relative(srcRoot, abs)
54
- : path.relative(projectRoot, abs)
52
+ const shippedPackages = path.join(PACKAGE_ROOT, "packages")
53
+ const projectPackages = projectPackagesDir()
54
+
55
+ let relative
56
+
57
+ if (isWithin(shippedPackages, abs)) {
58
+ relative = path.join("packages", path.relative(shippedPackages, abs))
59
+ } else if (isWithin(projectPackages, abs)) {
60
+ relative = path.join(path.basename(projectPackages), path.relative(projectPackages, abs))
61
+ } else if (isWithin(srcRoot, abs)) {
62
+ relative = path.relative(srcRoot, abs)
63
+ } else if (isWithin(projectRoot, abs)) {
64
+ relative = path.relative(projectRoot, abs)
65
+ } else {
66
+ const stripped = path.relative(projectRoot, abs).split(path.sep).filter(seg => seg !== "..")
67
+ relative = stripped.length ? path.join(...stripped) : path.basename(abs)
68
+ }
55
69
 
56
70
  return path.resolve("dist", relative.replace(/\.slim$/, ".js"))
57
71
  }