@marko/run 0.1.13 → 0.1.15

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.
@@ -55,7 +55,6 @@ var virtualRoutesPrefix = `${virtualFilePrefix}/routes`;
55
55
  var virtualRuntimePrefix = `${virtualFilePrefix}/internal`;
56
56
  var httpVerbs = ["get", "post", "put", "delete"];
57
57
  var serverEntryQuery = "?marko-server-entry";
58
- var browserEntryQuery = "?marko-browser-entry";
59
58
  var RoutableFileTypes = {
60
59
  Page: "page",
61
60
  Layout: "layout",
@@ -73,9 +72,6 @@ var routeableFileRegex = new RegExp(
73
72
  `^[+](?:${markoFiles}|${nonMarkoFiles})$`,
74
73
  "i"
75
74
  );
76
- function isRoutableFile(filename) {
77
- return routeableFileRegex.test(filename);
78
- }
79
75
  function matchRoutableFile(filename) {
80
76
  const match = filename.match(routeableFileRegex);
81
77
  return match && (match[1] || match[3]).toLowerCase();
@@ -1341,13 +1337,9 @@ var getExternalAdapterOptions = (viteConfig) => getConfig(viteConfig, AdapterCon
1341
1337
  // src/vite/plugin.ts
1342
1338
  var import_url2 = require("url");
1343
1339
  var __dirname = import_path2.default.dirname((0, import_url2.fileURLToPath)(__importMetaURL));
1344
- var markoExt = ".marko";
1345
1340
  var POSIX_SEP = "/";
1346
1341
  var WINDOWS_SEP = "\\";
1347
1342
  var normalizePath = import_path2.default.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
1348
- function isMarkoFile(id) {
1349
- return id.endsWith(markoExt);
1350
- }
1351
1343
  function markoRun(opts = {}) {
1352
1344
  let { routesDir, adapter, ...markoVitePluginOptions } = opts;
1353
1345
  let compiler;
@@ -1578,15 +1570,14 @@ function markoRun(opts = {}) {
1578
1570
  configureServer(_server) {
1579
1571
  devServer = _server;
1580
1572
  devServer.watcher.on("all", async (type, filename) => {
1581
- const file = import_path2.default.parse(filename);
1582
- if (filename.startsWith(resolvedRoutesDir) && isRoutableFile(file.base)) {
1573
+ const routableFileType = matchRoutableFile(import_path2.default.parse(filename).base);
1574
+ if (filename.startsWith(resolvedRoutesDir) && routableFileType) {
1583
1575
  if (type === "add") {
1584
1576
  isStale = true;
1585
1577
  } else if (type === "unlink") {
1586
1578
  isStale = true;
1587
1579
  } else if (type === "change") {
1588
- const match = matchRoutableFile(file.base);
1589
- if (match === RoutableFileTypes.Handler) {
1580
+ if (routableFileType === RoutableFileTypes.Handler) {
1590
1581
  isStale = true;
1591
1582
  }
1592
1583
  }
@@ -1621,7 +1612,7 @@ function markoRun(opts = {}) {
1621
1612
  extractVerbs = isBuild ? getVerbsFromFileBuild.bind(null, this) : getVerbsFromFileDev.bind(null, devServer);
1622
1613
  }
1623
1614
  },
1624
- async resolveId(importee, importer, { ssr }) {
1615
+ async resolveId(importee, importer) {
1625
1616
  let resolved;
1626
1617
  if (importee.startsWith(virtualRuntimePrefix)) {
1627
1618
  return this.resolve(
@@ -1643,14 +1634,14 @@ function markoRun(opts = {}) {
1643
1634
  }
1644
1635
  if (virtualFiles.has(importee)) {
1645
1636
  resolved = importee;
1646
- if (isBuild && !ssr && isMarkoFile(resolved)) {
1647
- resolved += browserEntryQuery;
1648
- }
1649
1637
  }
1650
1638
  return resolved || null;
1651
1639
  },
1652
1640
  async load(id) {
1653
1641
  var _a;
1642
+ if (id.endsWith(serverEntryQuery)) {
1643
+ id = id.slice(0, -serverEntryQuery.length);
1644
+ }
1654
1645
  if (virtualFiles.has(id)) {
1655
1646
  if (!isRendered) {
1656
1647
  await renderVirtualFiles();
@@ -13,7 +13,6 @@ var virtualRoutesPrefix = `${virtualFilePrefix}/routes`;
13
13
  var virtualRuntimePrefix = `${virtualFilePrefix}/internal`;
14
14
  var httpVerbs = ["get", "post", "put", "delete"];
15
15
  var serverEntryQuery = "?marko-server-entry";
16
- var browserEntryQuery = "?marko-browser-entry";
17
16
  var RoutableFileTypes = {
18
17
  Page: "page",
19
18
  Layout: "layout",
@@ -31,9 +30,6 @@ var routeableFileRegex = new RegExp(
31
30
  `^[+](?:${markoFiles}|${nonMarkoFiles})$`,
32
31
  "i"
33
32
  );
34
- function isRoutableFile(filename) {
35
- return routeableFileRegex.test(filename);
36
- }
37
33
  function matchRoutableFile(filename) {
38
34
  const match = filename.match(routeableFileRegex);
39
35
  return match && (match[1] || match[3]).toLowerCase();
@@ -1299,13 +1295,9 @@ var getExternalAdapterOptions = (viteConfig) => getConfig(viteConfig, AdapterCon
1299
1295
  // src/vite/plugin.ts
1300
1296
  import { fileURLToPath } from "url";
1301
1297
  var __dirname = path2.dirname(fileURLToPath(import.meta.url));
1302
- var markoExt = ".marko";
1303
1298
  var POSIX_SEP = "/";
1304
1299
  var WINDOWS_SEP = "\\";
1305
1300
  var normalizePath = path2.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
1306
- function isMarkoFile(id) {
1307
- return id.endsWith(markoExt);
1308
- }
1309
1301
  function markoRun(opts = {}) {
1310
1302
  let { routesDir, adapter, ...markoVitePluginOptions } = opts;
1311
1303
  let compiler;
@@ -1536,15 +1528,14 @@ function markoRun(opts = {}) {
1536
1528
  configureServer(_server) {
1537
1529
  devServer = _server;
1538
1530
  devServer.watcher.on("all", async (type, filename) => {
1539
- const file = path2.parse(filename);
1540
- if (filename.startsWith(resolvedRoutesDir) && isRoutableFile(file.base)) {
1531
+ const routableFileType = matchRoutableFile(path2.parse(filename).base);
1532
+ if (filename.startsWith(resolvedRoutesDir) && routableFileType) {
1541
1533
  if (type === "add") {
1542
1534
  isStale = true;
1543
1535
  } else if (type === "unlink") {
1544
1536
  isStale = true;
1545
1537
  } else if (type === "change") {
1546
- const match = matchRoutableFile(file.base);
1547
- if (match === RoutableFileTypes.Handler) {
1538
+ if (routableFileType === RoutableFileTypes.Handler) {
1548
1539
  isStale = true;
1549
1540
  }
1550
1541
  }
@@ -1579,7 +1570,7 @@ function markoRun(opts = {}) {
1579
1570
  extractVerbs = isBuild ? getVerbsFromFileBuild.bind(null, this) : getVerbsFromFileDev.bind(null, devServer);
1580
1571
  }
1581
1572
  },
1582
- async resolveId(importee, importer, { ssr }) {
1573
+ async resolveId(importee, importer) {
1583
1574
  let resolved;
1584
1575
  if (importee.startsWith(virtualRuntimePrefix)) {
1585
1576
  return this.resolve(
@@ -1601,14 +1592,14 @@ function markoRun(opts = {}) {
1601
1592
  }
1602
1593
  if (virtualFiles.has(importee)) {
1603
1594
  resolved = importee;
1604
- if (isBuild && !ssr && isMarkoFile(resolved)) {
1605
- resolved += browserEntryQuery;
1606
- }
1607
1595
  }
1608
1596
  return resolved || null;
1609
1597
  },
1610
1598
  async load(id) {
1611
1599
  var _a;
1600
+ if (id.endsWith(serverEntryQuery)) {
1601
+ id = id.slice(0, -serverEntryQuery.length);
1602
+ }
1612
1603
  if (virtualFiles.has(id)) {
1613
1604
  if (!isRendered) {
1614
1605
  await renderVirtualFiles();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/run",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "The Marko application framework.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/marko-js/run/tree/main/packages/run",
@@ -112,7 +112,7 @@
112
112
  "typescript": "^4.7.4"
113
113
  },
114
114
  "dependencies": {
115
- "@marko/vite": "^2.4.4",
115
+ "@marko/vite": "^2.4.8",
116
116
  "cli-table3": "^0.6.3",
117
117
  "compression": "^1.7.4",
118
118
  "dotenv": "^16.0.3",