elm-pages 3.0.0-beta.4 → 3.0.0-beta.6
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/codegen/elm-pages-codegen.js +261 -153
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmi +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +4 -4
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +4 -4
- package/generator/src/build.js +18 -15
- package/generator/src/dev-server.js +17 -7
- package/generator/src/vite-utils.js +78 -0
- package/package.json +2 -2
- package/src/Pages/Generate.elm +445 -94
- package/src/Pages/Internal/Platform.elm +31 -24
|
@@ -24,6 +24,7 @@ const busboy = require("busboy");
|
|
|
24
24
|
const { createServer: createViteServer } = require("vite");
|
|
25
25
|
const cliVersion = require("../../package.json").version;
|
|
26
26
|
const esbuild = require("esbuild");
|
|
27
|
+
const { merge_vite_configs } = require("./vite-utils.js");
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* @param {{ port: string; base: string; https: boolean; debug: boolean; }} options
|
|
@@ -131,13 +132,22 @@ async function start(options) {
|
|
|
131
132
|
);
|
|
132
133
|
return {};
|
|
133
134
|
});
|
|
134
|
-
const vite = await createViteServer(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
const vite = await createViteServer(
|
|
136
|
+
merge_vite_configs(
|
|
137
|
+
{
|
|
138
|
+
server: {
|
|
139
|
+
middlewareMode: "ssr",
|
|
140
|
+
base: options.base,
|
|
141
|
+
port: options.port,
|
|
142
|
+
},
|
|
143
|
+
configFile: false,
|
|
144
|
+
root: process.cwd(),
|
|
145
|
+
base: options.base,
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
viteConfig
|
|
149
|
+
)
|
|
150
|
+
);
|
|
141
151
|
esbuild
|
|
142
152
|
.build({
|
|
143
153
|
entryPoints: ["./port-data-source"],
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** This code is from https://github.com/sveltejs/kit/blob/3b457f67d4d7c59fc63bb3f600a490e4dacc2e62/packages/kit/src/exports/vite/utils.js */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {...import('vite').UserConfig} configs
|
|
5
|
+
* @returns {import('vite').UserConfig}
|
|
6
|
+
*/
|
|
7
|
+
function merge_vite_configs(...configs) {
|
|
8
|
+
return deep_merge(
|
|
9
|
+
...configs.map((config) => ({
|
|
10
|
+
...config,
|
|
11
|
+
resolve: {
|
|
12
|
+
...config.resolve,
|
|
13
|
+
alias: normalize_alias(config.resolve?.alias || {}),
|
|
14
|
+
},
|
|
15
|
+
}))
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Takes zero or more objects and returns a new object that has all the values
|
|
21
|
+
* deeply merged together. None of the original objects will be mutated at any
|
|
22
|
+
* level, and the returned object will have no references to the original
|
|
23
|
+
* objects at any depth. If there's a conflict the last one wins, except for
|
|
24
|
+
* arrays which will be combined.
|
|
25
|
+
* @param {...Object} objects
|
|
26
|
+
* @returns {Record<string, any>} the merged object
|
|
27
|
+
*/
|
|
28
|
+
function deep_merge(...objects) {
|
|
29
|
+
const result = {};
|
|
30
|
+
/** @type {string[]} */
|
|
31
|
+
objects.forEach((o) => merge_into(result, o));
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* normalize kit.vite.resolve.alias as an array
|
|
37
|
+
* @param {import('vite').AliasOptions} o
|
|
38
|
+
* @returns {import('vite').Alias[]}
|
|
39
|
+
*/
|
|
40
|
+
function normalize_alias(o) {
|
|
41
|
+
if (Array.isArray(o)) return o;
|
|
42
|
+
return Object.entries(o).map(([find, replacement]) => ({
|
|
43
|
+
find,
|
|
44
|
+
replacement,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Merges b into a, recursively, mutating a.
|
|
50
|
+
* @param {Record<string, any>} a
|
|
51
|
+
* @param {Record<string, any>} b
|
|
52
|
+
*/
|
|
53
|
+
function merge_into(a, b) {
|
|
54
|
+
/**
|
|
55
|
+
* Checks for "plain old Javascript object", typically made as an object
|
|
56
|
+
* literal. Excludes Arrays and built-in types like Buffer.
|
|
57
|
+
* @param {any} x
|
|
58
|
+
*/
|
|
59
|
+
const is_plain_object = (x) =>
|
|
60
|
+
typeof x === "object" && x.constructor === Object;
|
|
61
|
+
|
|
62
|
+
for (const prop in b) {
|
|
63
|
+
if (is_plain_object(b[prop])) {
|
|
64
|
+
if (!is_plain_object(a[prop])) {
|
|
65
|
+
a[prop] = {};
|
|
66
|
+
}
|
|
67
|
+
merge_into(a[prop], b[prop]);
|
|
68
|
+
} else if (Array.isArray(b[prop])) {
|
|
69
|
+
if (!Array.isArray(a[prop])) {
|
|
70
|
+
a[prop] = [];
|
|
71
|
+
}
|
|
72
|
+
a[prop].push(...b[prop]);
|
|
73
|
+
} else {
|
|
74
|
+
a[prop] = b[prop];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
module.exports = { merge_vite_configs };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elm-pages",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.6",
|
|
4
4
|
"homepage": "https://elm-pages.com",
|
|
5
5
|
"moduleResolution": "node",
|
|
6
6
|
"description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"object-hash": "^2.2.0",
|
|
46
46
|
"serve-static": "^1.15.0",
|
|
47
47
|
"terser": "^5.14.2",
|
|
48
|
-
"vite": "^3.
|
|
48
|
+
"vite": "^3.1.8",
|
|
49
49
|
"which": "^2.0.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|