evolit 0.1.0-alpha.11 → 0.1.0-alpha.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evolit",
3
- "version": "0.1.0-alpha.11",
3
+ "version": "0.1.0-alpha.12",
4
4
  "description": "A convention-driven application framework for LitSX and web components.",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@4.10.3",
@@ -57,12 +57,12 @@ function isRelativeSpecifier(specifier) {
57
57
  );
58
58
  }
59
59
 
60
- function stripImportSuffix(specifier) {
61
- return specifier.split("?")[0].split("#")[0];
60
+ function stripImportSearchAndHash(specifier) {
61
+ return String(specifier).split("?")[0].split("#")[0];
62
62
  }
63
63
 
64
64
  function resolveRelativeClientImportPath(fromClientModule, specifier) {
65
- const normalizedSpecifier = stripImportSuffix(specifier);
65
+ const normalizedSpecifier = stripImportSearchAndHash(specifier);
66
66
  return path
67
67
  .normalize(path.join(path.dirname(fromClientModule), normalizedSpecifier))
68
68
  .split(path.sep)
@@ -573,7 +573,10 @@ async function resolveRelativeImportFilePath(fromFilePath, specifier) {
573
573
  return null;
574
574
  }
575
575
 
576
- const candidatePath = path.resolve(path.dirname(fromFilePath), specifier);
576
+ const candidatePath = path.resolve(
577
+ path.dirname(stripImportSearchAndHash(fromFilePath)),
578
+ stripImportSearchAndHash(specifier),
579
+ );
577
580
  const candidatePaths = [
578
581
  candidatePath,
579
582
  `${candidatePath}.js`,
@@ -1536,17 +1539,36 @@ async function bundleClientAssets(projectRoot, options = {}) {
1536
1539
  return isBareSpecifier(id);
1537
1540
  },
1538
1541
  plugins: [
1542
+ {
1543
+ name: "evolit-client-relative-imports",
1544
+ resolveId(source, importer) {
1545
+ if (!importer || !isRelativeSpecifier(source)) {
1546
+ return null;
1547
+ }
1548
+
1549
+ const cleanSource = stripImportSearchAndHash(source);
1550
+ if (cleanSource === source) {
1551
+ return null;
1552
+ }
1553
+
1554
+ return path.resolve(
1555
+ path.dirname(stripImportSearchAndHash(importer)),
1556
+ cleanSource,
1557
+ );
1558
+ },
1559
+ },
1539
1560
  {
1540
1561
  name: "evolit-client-input-sourcemaps",
1541
1562
  async load(id) {
1542
- if (!id.startsWith(clientRoot) || !id.endsWith(".mjs")) {
1563
+ const filePath = stripImportSearchAndHash(id);
1564
+ if (!filePath.startsWith(clientRoot) || !filePath.endsWith(".mjs")) {
1543
1565
  return null;
1544
1566
  }
1545
1567
 
1546
1568
  try {
1547
1569
  const [code, map] = await Promise.all([
1548
- fs.readFile(id, "utf8"),
1549
- fs.readFile(`${id}.map`, "utf8"),
1570
+ fs.readFile(filePath, "utf8"),
1571
+ fs.readFile(`${filePath}.map`, "utf8"),
1550
1572
  ]);
1551
1573
  return { code, map: JSON.parse(map) };
1552
1574
  } catch {