0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-08 08:09:14 -05:00

🐛 Fix cache issues with plugin runtime import uri

This commit is contained in:
Andrey Antukh 2024-10-09 10:43:50 +02:00 committed by Alonso Torres
parent 74f3379b5d
commit 28878caca9
2 changed files with 14 additions and 11 deletions

View file

@ -29,7 +29,7 @@
<script defer src="{{& polyfills}}"></script> <script defer src="{{& polyfills}}"></script>
{{/manifest}} {{/manifest}}
<script type="module" src="{{pluginRuntimeUri}}/index.js"></script> <script type="module" src="{{& pluginRuntimeUri}}"></script>
<script> <script>
window.penpotTranslations = JSON.parse({{& translations}}); window.penpotTranslations = JSON.parse({{& translations}});

View file

@ -181,14 +181,16 @@ export async function watch(baseDir, predicate, callback) {
} }
async function readShadowManifest() { async function readShadowManifest() {
const ts = Date.now();
try { try {
const manifestPath = "resources/public/js/manifest.json"; const manifestPath = "resources/public/js/manifest.json";
let content = await fs.readFile(manifestPath, { encoding: "utf8" }); let content = await fs.readFile(manifestPath, { encoding: "utf8" });
content = JSON.parse(content); content = JSON.parse(content);
const index = { const index = {
config: "js/config.js?ts=" + Date.now(), ts: ts,
polyfills: "js/polyfills.js?ts=" + Date.now(), config: "js/config.js?ts=" + ts,
polyfills: "js/polyfills.js?ts=" + ts,
}; };
for (let item of content) { for (let item of content) {
@ -198,12 +200,13 @@ async function readShadowManifest() {
return index; return index;
} catch (cause) { } catch (cause) {
return { return {
config: "js/config.js", ts: ts,
polyfills: "js/polyfills.js", config: "js/config.js?ts=" + ts,
main: "js/main.js", polyfills: "js/polyfills.js?ts=" + ts,
shared: "js/shared.js", main: "js/main.js?ts=" + ts,
worker: "js/worker.js", shared: "js/shared.js?ts=" + ts,
rasterizer: "js/rasterizer.js", worker: "js/worker.js?ts=" + ts,
rasterizer: "js/rasterizer.js?ts=" + ts,
}; };
} }
} }
@ -409,8 +412,8 @@ async function generateTemplates() {
const pluginRuntimeUri = const pluginRuntimeUri =
process.env.PENPOT_PLUGIN_DEV === "true" process.env.PENPOT_PLUGIN_DEV === "true"
? "http://localhost:4200" ? "http://localhost:4200/index.js?ts=" + manifest.ts
: "./plugins-runtime"; : "plugins-runtime/index.js?ts=" + manifest.ts;
content = await renderTemplate( content = await renderTemplate(
"resources/templates/index.mustache", "resources/templates/index.mustache",