@matthesketh/utopia-vite-plugin 0.1.0 → 0.3.0
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/index.cjs +30 -31
- package/dist/index.js +30 -31
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -55,10 +55,7 @@ function cssIdToUtopiaId(cssId) {
|
|
|
55
55
|
return raw.slice(0, -CSS_SUFFIX.length);
|
|
56
56
|
}
|
|
57
57
|
function utopiaPlugin(options = {}) {
|
|
58
|
-
const {
|
|
59
|
-
include = `**/*${UTOPIA_EXT}`,
|
|
60
|
-
exclude
|
|
61
|
-
} = options;
|
|
58
|
+
const { include = `**/*${UTOPIA_EXT}`, exclude } = options;
|
|
62
59
|
let filter;
|
|
63
60
|
let server;
|
|
64
61
|
const prevDescriptors = /* @__PURE__ */ new Map();
|
|
@@ -174,22 +171,16 @@ import ${JSON.stringify(cssImportId)};
|
|
|
174
171
|
}
|
|
175
172
|
const oldDescriptor = prevDescriptors.get(file);
|
|
176
173
|
prevDescriptors.set(file, newDescriptor);
|
|
177
|
-
const templateChanged = didBlockChange(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
);
|
|
181
|
-
const scriptChanged = didBlockChange(
|
|
182
|
-
oldDescriptor?.script,
|
|
183
|
-
newDescriptor.script
|
|
184
|
-
);
|
|
185
|
-
const styleChanged = didBlockChange(
|
|
186
|
-
oldDescriptor?.style,
|
|
187
|
-
newDescriptor.style
|
|
188
|
-
);
|
|
174
|
+
const templateChanged = didBlockChange(oldDescriptor?.template, newDescriptor.template);
|
|
175
|
+
const scriptChanged = didBlockChange(oldDescriptor?.script, newDescriptor.script);
|
|
176
|
+
const styleChanged = didBlockChange(oldDescriptor?.style, newDescriptor.style);
|
|
189
177
|
if (styleChanged && !templateChanged && !scriptChanged) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
178
|
+
let result;
|
|
179
|
+
try {
|
|
180
|
+
result = (0, import_utopia_compiler.compile)(source, { filename: file });
|
|
181
|
+
} catch {
|
|
182
|
+
return void 0;
|
|
183
|
+
}
|
|
193
184
|
if (result.css) {
|
|
194
185
|
cssCache.set(file, result.css);
|
|
195
186
|
} else {
|
|
@@ -208,13 +199,14 @@ import ${JSON.stringify(cssImportId)};
|
|
|
208
199
|
affectedModules.push(mod);
|
|
209
200
|
}
|
|
210
201
|
if (styleChanged) {
|
|
211
|
-
|
|
212
|
-
filename: file
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
202
|
+
try {
|
|
203
|
+
const result = (0, import_utopia_compiler.compile)(source, { filename: file });
|
|
204
|
+
if (result.css) {
|
|
205
|
+
cssCache.set(file, result.css);
|
|
206
|
+
} else {
|
|
207
|
+
cssCache.delete(file);
|
|
208
|
+
}
|
|
209
|
+
} catch {
|
|
218
210
|
}
|
|
219
211
|
const cssId = VIRTUAL_PREFIX + toCssId(file);
|
|
220
212
|
const cssModule = hmrServer.moduleGraph.getModuleById(cssId);
|
|
@@ -260,15 +252,22 @@ function defineConfig(userConfig = {}) {
|
|
|
260
252
|
...userOptimizeDeps,
|
|
261
253
|
// Exclude UtopiaJS packages from Vite's dependency pre-bundling so
|
|
262
254
|
// they go through the normal plugin pipeline.
|
|
263
|
-
exclude: mergeUnique(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
255
|
+
exclude: mergeUnique(userOptimizeDeps?.exclude ?? [], [
|
|
256
|
+
"@matthesketh/utopia-core",
|
|
257
|
+
"@matthesketh/utopia-runtime",
|
|
258
|
+
"@matthesketh/utopia-router",
|
|
259
|
+
"@matthesketh/utopia-server"
|
|
260
|
+
])
|
|
267
261
|
},
|
|
268
262
|
ssr: {
|
|
269
263
|
// Ensure UtopiaJS packages are bundled during SSR builds so the
|
|
270
264
|
// runtime swap alias is applied correctly.
|
|
271
|
-
noExternal: [
|
|
265
|
+
noExternal: [
|
|
266
|
+
"@matthesketh/utopia-core",
|
|
267
|
+
"@matthesketh/utopia-runtime",
|
|
268
|
+
"@matthesketh/utopia-router",
|
|
269
|
+
"@matthesketh/utopia-server"
|
|
270
|
+
]
|
|
272
271
|
}
|
|
273
272
|
};
|
|
274
273
|
}
|
package/dist/index.js
CHANGED
|
@@ -20,10 +20,7 @@ function cssIdToUtopiaId(cssId) {
|
|
|
20
20
|
return raw.slice(0, -CSS_SUFFIX.length);
|
|
21
21
|
}
|
|
22
22
|
function utopiaPlugin(options = {}) {
|
|
23
|
-
const {
|
|
24
|
-
include = `**/*${UTOPIA_EXT}`,
|
|
25
|
-
exclude
|
|
26
|
-
} = options;
|
|
23
|
+
const { include = `**/*${UTOPIA_EXT}`, exclude } = options;
|
|
27
24
|
let filter;
|
|
28
25
|
let server;
|
|
29
26
|
const prevDescriptors = /* @__PURE__ */ new Map();
|
|
@@ -139,22 +136,16 @@ import ${JSON.stringify(cssImportId)};
|
|
|
139
136
|
}
|
|
140
137
|
const oldDescriptor = prevDescriptors.get(file);
|
|
141
138
|
prevDescriptors.set(file, newDescriptor);
|
|
142
|
-
const templateChanged = didBlockChange(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
);
|
|
146
|
-
const scriptChanged = didBlockChange(
|
|
147
|
-
oldDescriptor?.script,
|
|
148
|
-
newDescriptor.script
|
|
149
|
-
);
|
|
150
|
-
const styleChanged = didBlockChange(
|
|
151
|
-
oldDescriptor?.style,
|
|
152
|
-
newDescriptor.style
|
|
153
|
-
);
|
|
139
|
+
const templateChanged = didBlockChange(oldDescriptor?.template, newDescriptor.template);
|
|
140
|
+
const scriptChanged = didBlockChange(oldDescriptor?.script, newDescriptor.script);
|
|
141
|
+
const styleChanged = didBlockChange(oldDescriptor?.style, newDescriptor.style);
|
|
154
142
|
if (styleChanged && !templateChanged && !scriptChanged) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
143
|
+
let result;
|
|
144
|
+
try {
|
|
145
|
+
result = compile(source, { filename: file });
|
|
146
|
+
} catch {
|
|
147
|
+
return void 0;
|
|
148
|
+
}
|
|
158
149
|
if (result.css) {
|
|
159
150
|
cssCache.set(file, result.css);
|
|
160
151
|
} else {
|
|
@@ -173,13 +164,14 @@ import ${JSON.stringify(cssImportId)};
|
|
|
173
164
|
affectedModules.push(mod);
|
|
174
165
|
}
|
|
175
166
|
if (styleChanged) {
|
|
176
|
-
|
|
177
|
-
filename: file
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
167
|
+
try {
|
|
168
|
+
const result = compile(source, { filename: file });
|
|
169
|
+
if (result.css) {
|
|
170
|
+
cssCache.set(file, result.css);
|
|
171
|
+
} else {
|
|
172
|
+
cssCache.delete(file);
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
183
175
|
}
|
|
184
176
|
const cssId = VIRTUAL_PREFIX + toCssId(file);
|
|
185
177
|
const cssModule = hmrServer.moduleGraph.getModuleById(cssId);
|
|
@@ -225,15 +217,22 @@ function defineConfig(userConfig = {}) {
|
|
|
225
217
|
...userOptimizeDeps,
|
|
226
218
|
// Exclude UtopiaJS packages from Vite's dependency pre-bundling so
|
|
227
219
|
// they go through the normal plugin pipeline.
|
|
228
|
-
exclude: mergeUnique(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
220
|
+
exclude: mergeUnique(userOptimizeDeps?.exclude ?? [], [
|
|
221
|
+
"@matthesketh/utopia-core",
|
|
222
|
+
"@matthesketh/utopia-runtime",
|
|
223
|
+
"@matthesketh/utopia-router",
|
|
224
|
+
"@matthesketh/utopia-server"
|
|
225
|
+
])
|
|
232
226
|
},
|
|
233
227
|
ssr: {
|
|
234
228
|
// Ensure UtopiaJS packages are bundled during SSR builds so the
|
|
235
229
|
// runtime swap alias is applied correctly.
|
|
236
|
-
noExternal: [
|
|
230
|
+
noExternal: [
|
|
231
|
+
"@matthesketh/utopia-core",
|
|
232
|
+
"@matthesketh/utopia-runtime",
|
|
233
|
+
"@matthesketh/utopia-router",
|
|
234
|
+
"@matthesketh/utopia-server"
|
|
235
|
+
]
|
|
237
236
|
}
|
|
238
237
|
};
|
|
239
238
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matthesketh/utopia-vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Vite plugin for UtopiaJS .utopia files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@matthesketh/utopia-compiler": "0.
|
|
42
|
+
"@matthesketh/utopia-compiler": "0.3.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vite": "^6.0.0 || ^7.0.0"
|