@inkandswitch/patchwork 0.7.0 → 0.7.1
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/CHANGELOG.md +8 -0
- package/dist/vite/build-info-plugin.js +4 -0
- package/dist/vite/dev-plugin.js +12 -0
- package/dist/vite/static-plugin.js +5 -0
- package/package.json +2 -2
- package/src/vite/build-info-plugin.ts +3 -0
- package/src/vite/dev-plugin.ts +19 -0
- package/src/vite/static-plugin.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @inkandswitch/patchwork
|
|
2
2
|
|
|
3
|
+
## 0.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8b9206d: Don't copy `static` sources or write `build-info.json` when a dev server shuts
|
|
8
|
+
down. `closeBundle` runs then too, so stopping `vite` was filling `dist/` with
|
|
9
|
+
a copy of every static source.
|
|
10
|
+
|
|
3
11
|
## 0.7.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -42,13 +42,17 @@ export function buildInfoPlugin(options = {}) {
|
|
|
42
42
|
return null;
|
|
43
43
|
let root;
|
|
44
44
|
let outDir;
|
|
45
|
+
let serve = false;
|
|
45
46
|
return {
|
|
46
47
|
name: "@patchwork/build-info",
|
|
47
48
|
configResolved(config) {
|
|
48
49
|
root = config.root;
|
|
49
50
|
outDir = join(config.root, config.build.outDir);
|
|
51
|
+
serve = config.command === "serve";
|
|
50
52
|
},
|
|
51
53
|
async closeBundle() {
|
|
54
|
+
if (serve)
|
|
55
|
+
return;
|
|
52
56
|
const sources = resolveStatic(options, root).map((source) => source.packageDirectory
|
|
53
57
|
? { from: source.from, ...describe(source.packageDirectory) }
|
|
54
58
|
: { from: source.from, revision: revision(source.path) });
|
package/dist/vite/dev-plugin.js
CHANGED
|
@@ -14,6 +14,7 @@ const stylesheets = {
|
|
|
14
14
|
[PATCHWORK_CSS]: fileURLToPath(import.meta.resolve("@inkandswitch/patchwork/global.css")),
|
|
15
15
|
[BOOTLOADER_CSS]: fileURLToPath(import.meta.resolve("@inkandswitch/patchwork-bootloader/global.css")),
|
|
16
16
|
};
|
|
17
|
+
const builtinPaths = new Map(Object.entries(builtins).map(([id, fileName]) => [fileName, id]));
|
|
17
18
|
/**
|
|
18
19
|
* Workers are `type: "module"` scripts the browser fetches directly, so import
|
|
19
20
|
* maps don't apply to them and their heavy imports have to resolve to real
|
|
@@ -92,6 +93,17 @@ export function devPlugin(options = {}) {
|
|
|
92
93
|
}
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
96
|
+
// A worker script is fetched by URL, and import maps don't apply to
|
|
97
|
+
// those, so code that starts one reaches for the /packages/… path the
|
|
98
|
+
// build emits. In dev those are the optimized deps the page's import
|
|
99
|
+
// map points at — same module, one URL over.
|
|
100
|
+
const builtin = builtinPaths.get(pathname);
|
|
101
|
+
if (builtin) {
|
|
102
|
+
response.statusCode = 302;
|
|
103
|
+
response.setHeader("Location", `/@id/${encodeURI(devDependencyId(builtin))}`);
|
|
104
|
+
response.end();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
95
107
|
const binary = wasm.get(pathname);
|
|
96
108
|
if (binary) {
|
|
97
109
|
try {
|
|
@@ -112,6 +112,7 @@ export function staticPlugin(options = {}) {
|
|
|
112
112
|
let root;
|
|
113
113
|
let outDir;
|
|
114
114
|
let base = "/";
|
|
115
|
+
let serve = false;
|
|
115
116
|
let logger;
|
|
116
117
|
return {
|
|
117
118
|
name: "@patchwork/static",
|
|
@@ -120,9 +121,13 @@ export function staticPlugin(options = {}) {
|
|
|
120
121
|
root = config.root;
|
|
121
122
|
outDir = resolve(config.root, config.build.outDir);
|
|
122
123
|
base = config.base;
|
|
124
|
+
serve = config.command === "serve";
|
|
123
125
|
logger = config.logger;
|
|
124
126
|
},
|
|
125
127
|
async closeBundle() {
|
|
128
|
+
// also called when a dev server shuts down, which has nothing to copy
|
|
129
|
+
if (serve)
|
|
130
|
+
return;
|
|
126
131
|
for (const source of sources) {
|
|
127
132
|
const paths = source.file ? [""] : await files(source.path);
|
|
128
133
|
const kept = [];
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "git+https://github.com/inkandswitch/patchwork-system.git",
|
|
6
6
|
"directory": "core/patchwork"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.7.
|
|
8
|
+
"version": "0.7.1",
|
|
9
9
|
"author": "Ink & Switch",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"license": "MIT",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"vite-plugin-wasm": "^3.6.0",
|
|
46
46
|
"@inkandswitch/patchwork-bootloader": "^0.6.2",
|
|
47
47
|
"@inkandswitch/patchwork-filesystem": "^0.2.5",
|
|
48
|
-
"@inkandswitch/patchwork-plugins": "^1.2.0",
|
|
49
48
|
"@inkandswitch/patchwork-providers": "^0.5.0",
|
|
49
|
+
"@inkandswitch/patchwork-plugins": "^1.2.0",
|
|
50
50
|
"@inkandswitch/patchwork-elements": "^6.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -49,13 +49,16 @@ export function buildInfoPlugin(
|
|
|
49
49
|
if (!options.buildInfo) return null;
|
|
50
50
|
let root: string;
|
|
51
51
|
let outDir: string;
|
|
52
|
+
let serve = false;
|
|
52
53
|
return {
|
|
53
54
|
name: "@patchwork/build-info",
|
|
54
55
|
configResolved(config) {
|
|
55
56
|
root = config.root;
|
|
56
57
|
outDir = join(config.root, config.build.outDir);
|
|
58
|
+
serve = config.command === "serve";
|
|
57
59
|
},
|
|
58
60
|
async closeBundle() {
|
|
61
|
+
if (serve) return;
|
|
59
62
|
const sources = resolveStatic(options, root).map((source) =>
|
|
60
63
|
source.packageDirectory
|
|
61
64
|
? { from: source.from, ...describe(source.packageDirectory) }
|
package/src/vite/dev-plugin.ts
CHANGED
|
@@ -23,6 +23,10 @@ const stylesheets: Record<string, string> = {
|
|
|
23
23
|
),
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
const builtinPaths = new Map(
|
|
27
|
+
Object.entries(builtins).map(([id, fileName]) => [fileName, id])
|
|
28
|
+
);
|
|
29
|
+
|
|
26
30
|
/**
|
|
27
31
|
* Workers are `type: "module"` scripts the browser fetches directly, so import
|
|
28
32
|
* maps don't apply to them and their heavy imports have to resolve to real
|
|
@@ -117,6 +121,21 @@ export function devPlugin(options: PatchworkVitePluginOptions = {}): Plugin {
|
|
|
117
121
|
return;
|
|
118
122
|
}
|
|
119
123
|
|
|
124
|
+
// A worker script is fetched by URL, and import maps don't apply to
|
|
125
|
+
// those, so code that starts one reaches for the /packages/… path the
|
|
126
|
+
// build emits. In dev those are the optimized deps the page's import
|
|
127
|
+
// map points at — same module, one URL over.
|
|
128
|
+
const builtin = builtinPaths.get(pathname);
|
|
129
|
+
if (builtin) {
|
|
130
|
+
response.statusCode = 302;
|
|
131
|
+
response.setHeader(
|
|
132
|
+
"Location",
|
|
133
|
+
`/@id/${encodeURI(devDependencyId(builtin))}`
|
|
134
|
+
);
|
|
135
|
+
response.end();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
120
139
|
const binary = wasm.get(pathname);
|
|
121
140
|
if (binary) {
|
|
122
141
|
try {
|
|
@@ -170,6 +170,7 @@ export function staticPlugin(
|
|
|
170
170
|
let root: string;
|
|
171
171
|
let outDir: string;
|
|
172
172
|
let base = "/";
|
|
173
|
+
let serve = false;
|
|
173
174
|
let logger: Logger;
|
|
174
175
|
return {
|
|
175
176
|
name: "@patchwork/static",
|
|
@@ -178,9 +179,12 @@ export function staticPlugin(
|
|
|
178
179
|
root = config.root;
|
|
179
180
|
outDir = resolve(config.root, config.build.outDir);
|
|
180
181
|
base = config.base;
|
|
182
|
+
serve = config.command === "serve";
|
|
181
183
|
logger = config.logger;
|
|
182
184
|
},
|
|
183
185
|
async closeBundle() {
|
|
186
|
+
// also called when a dev server shuts down, which has nothing to copy
|
|
187
|
+
if (serve) return;
|
|
184
188
|
for (const source of sources) {
|
|
185
189
|
const paths = source.file ? [""] : await files(source.path);
|
|
186
190
|
const kept: string[] = [];
|