minista 3.1.3 → 3.1.5

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/build.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { pathToFileURL } from "node:url";
2
3
  import fs from "fs-extra";
3
4
  import {
4
5
  defineConfig as defineViteConfig,
@@ -95,7 +96,8 @@ async function build(inlineConfig = {}) {
95
96
  const ssgPath = path.join(tempDir, "ssg.mjs");
96
97
  const ssgData = ssgItems[0].source || ssgItems[0].code || "";
97
98
  await fs.outputFile(ssgPath, ssgData);
98
- const { runSsg } = await import(ssgPath);
99
+ const ssgUrl = pathToFileURL(ssgPath).href;
100
+ const { runSsg } = await import(ssgUrl);
99
101
  ssgPages = await runSsg(config);
100
102
  }
101
103
  if (ssgPages.length > 0) {
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { fileURLToPath, pathToFileURL } from "node:url";
2
3
  import fs from "fs-extra";
3
4
  import { normalizePath } from "vite";
4
5
  import { build as esBuild } from "esbuild";
@@ -33,8 +34,10 @@ async function resolveUserConfig(inlineConfig) {
33
34
  ".minista",
34
35
  "minista.config.mjs"
35
36
  );
37
+ const entryPointUrl = pathToFileURL(path.resolve(configPath));
38
+ const entryPointPath = fileURLToPath(entryPointUrl);
36
39
  await esBuild({
37
- entryPoints: [configPath],
40
+ entryPoints: [entryPointPath],
38
41
  outfile: compiledConfigPath,
39
42
  bundle: true,
40
43
  format: "esm",
@@ -45,17 +48,19 @@ async function resolveUserConfig(inlineConfig) {
45
48
  name: "minista-esbuild-plugin:external",
46
49
  setup(build) {
47
50
  let filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/;
48
- build.onResolve({ filter }, (args) => ({
49
- path: args.path,
50
- external: true
51
- }));
51
+ build.onResolve({ filter }, (args) => {
52
+ if (args.path === entryPointPath) {
53
+ return { path: args.path, external: false };
54
+ }
55
+ return { path: args.path, external: true };
56
+ });
52
57
  }
53
58
  }
54
59
  ]
55
60
  }).catch((err) => {
56
61
  console.error(err);
57
62
  });
58
- const { default: compiledUserConfig } = await import(compiledConfigPath);
63
+ const { default: compiledUserConfig } = await import(pathToFileURL(compiledConfigPath).href);
59
64
  const customDeepmerge = deepmergeCustom({
60
65
  mergeArrays: false
61
66
  });
@@ -40,6 +40,9 @@ async function generatePages({
40
40
  hydrateEl?.remove();
41
41
  }
42
42
  data = parsedHtml.toString();
43
+ data = data.replace(/src="([^"]+)"/g, (match, p1) => {
44
+ return `src="${p1.replace(/\\/g, "/")}"`;
45
+ });
43
46
  if (useHtml) {
44
47
  data = beautify.html(data, htmlOptions);
45
48
  }
@@ -18,7 +18,7 @@ function getStories(config) {
18
18
  const jsStories = Object.keys(JS_STORIES).map((storyFileKey) => {
19
19
  const storyFile = JS_STORIES[storyFileKey];
20
20
  const storyMeta = storyFile.default;
21
- if (!storyMeta?.id || !storyMeta?.title) {
21
+ if (!storyMeta?.id && !storyMeta?.title) {
22
22
  return [];
23
23
  }
24
24
  const storyBase = "/" + config.main.storyapp.outDir;
@@ -17,7 +17,7 @@ function getLinkTag({
17
17
  assetPath = path.join("/", "@minista-project-root", input);
18
18
  return `<link rel="stylesheet"${attrs} href="${assetPath}">`;
19
19
  }
20
- assetPath = path.join(resolvedBase, assets.outDir, name + ".css");
20
+ assetPath = `${resolvedBase}${assets.outDir}/${name}.css`;
21
21
  assetPath = assetPath.replace(/-ministaDuplicateName\d*/, "");
22
22
  return `<link rel="stylesheet"${attrs} href="${assetPath}" ${flags.entried}>`;
23
23
  }
@@ -35,10 +35,10 @@ function getScriptTag({
35
35
  attrs = attributes ? " " + attributes : ` type="module"`;
36
36
  attrs = attributes === false ? "" : attrs;
37
37
  if (command === "serve") {
38
- assetPath = path.join("/", "@minista-project-root", input);
38
+ assetPath = `/@minista-project-root/${input}`;
39
39
  return `<script${attrs} src="${assetPath}"></script>`;
40
40
  }
41
- assetPath = path.join(resolvedBase, assets.outDir, name + ".js");
41
+ assetPath = `${resolvedBase}${assets.outDir}/${name}.js`;
42
42
  assetPath = assetPath.replace(/-ministaDuplicateName\d*/, "");
43
43
  return `<script${attrs} src="${assetPath}" ${flags.entried}></script>`;
44
44
  }
@@ -105,16 +105,8 @@ function transformTags({
105
105
  hydrateHeadScriptTag = `<script type="module" src="${hydratePath}"></script>`;
106
106
  }
107
107
  if (command === "build") {
108
- const bundlePath = path.join(
109
- resolvedBase,
110
- assets.outDir,
111
- assets.bundle.outName + ".css"
112
- );
113
- const hydratePath = path.join(
114
- resolvedBase,
115
- assets.outDir,
116
- assets.partial.outName + ".js"
117
- );
108
+ const bundlePath = `${resolvedBase}${assets.outDir}/${assets.bundle.outName}.css`;
109
+ const hydratePath = `${resolvedBase}${assets.outDir}/${assets.partial.outName}.js`;
118
110
  bundleHeadLinkTag = `<link rel="stylesheet" href="${bundlePath}" ${flags.entried} ${flags.bundle}>`;
119
111
  hydrateHeadScriptTag = `<script type="module" src="${hydratePath}" ${flags.entried} ${flags.hydrate}></script>`;
120
112
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minista",
3
3
  "description": "Static site generator with 100% static export from React and Vite",
4
- "version": "3.1.3",
4
+ "version": "3.1.5",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=14.15.0"
@@ -52,7 +52,7 @@
52
52
  "build:src": "tsx ../../scripts/build-sources.ts",
53
53
  "build:type": "tsc",
54
54
  "clean": "rimraf ./dist",
55
- "prepublishOnly": "npm run clean && npm run build"
55
+ "prepublishOnly": "npm run build"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "less": "*",
@@ -82,15 +82,15 @@
82
82
  "cac": "^6.7.14",
83
83
  "dayjs": "^1.11.9",
84
84
  "deepmerge-ts": "^5.1.0",
85
- "esbuild": "^0.18.15",
86
- "fast-glob": "^3.3.0",
85
+ "esbuild": "^0.18.17",
86
+ "fast-glob": "^3.3.1",
87
87
  "fs-extra": "^11.1.1",
88
88
  "iconv-lite": "^0.6.3",
89
89
  "image-size": "^1.0.2",
90
90
  "js-beautify": "^1.14.9",
91
91
  "mime-types": "^2.1.35",
92
92
  "mojigiri": "^0.3.0",
93
- "node-fetch": "^3.3.1",
93
+ "node-fetch": "^3.3.2",
94
94
  "node-html-parser": "^6.1.5",
95
95
  "picocolors": "^1.0.0",
96
96
  "picomatch": "^2.3.1",
@@ -106,6 +106,6 @@
106
106
  "remark-rehype": "^10.1.0",
107
107
  "sharp": "^0.32.4",
108
108
  "unified": "^10.1.2",
109
- "vite": "^4.4.6"
109
+ "vite": "^4.4.7"
110
110
  }
111
111
  }