Skip to content

Commit

Permalink
Fix/web accessible resources script modules (#855)
Browse files Browse the repository at this point in the history
* include script module entry file in web resources

* tests(client) fix loading page script

* tests(update) update output snapshots

* Create eight-stingrays-provide.md

* tests(update) update output snapshots 2
  • Loading branch information
jacksteamdev committed Jan 10, 2024
1 parent a0d4592 commit ce9fe1c
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-stingrays-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@crxjs/vite-plugin": patch
---

Fix/web accessible resources script modules
4 changes: 2 additions & 2 deletions packages/vite-plugin/src/client/es/loading-page-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ do {
}
} while (!ready)

// reload the extension to load the built files from the dev server
chrome.runtime.reload()
// reload the page to load the built files from the dev server
location.reload()

export {}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export const pluginWebAccessibleResources: CrxPluginFn = () => {
contentScripts.get(key)!.css = [...css]

// loader files import the entry, so entry file must be web accessible
if (type === 'loader') imports.add(fileName)
if (type === 'loader' || isDynamicScript)
imports.add(fileName)

const resource:
| WebAccessibleResourceById
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ do {
await new Promise((resolve) => setTimeout(resolve, timeout));
}
} while (!ready);
chrome.runtime.reload();
location.reload();
"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ do {
await new Promise((resolve) => setTimeout(resolve, timeout));
}
} while (!ready);
chrome.runtime.reload();
location.reload();
"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ do {
await new Promise((resolve) => setTimeout(resolve, timeout));
}
} while (!ready);
chrome.runtime.reload();
location.reload();
"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ do {
await new Promise((resolve) => setTimeout(resolve, timeout));
}
} while (!ready);
chrome.runtime.reload();
location.reload();
"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ do {
await new Promise((resolve) => setTimeout(resolve, timeout));
}
} while (!ready);
chrome.runtime.reload();
location.reload();
"
`;

Expand All @@ -137,7 +137,7 @@ import 'http://localhost:3000/@crx/client-worker';
`;

exports[`serve fs output > src/App.svelte.js 1`] = `
"import { createHotContext as __vite__createHotContext } from \\"/vendor/vite-client.js\\";import.meta.hot = __vite__createHotContext(\\"/src/App.svelte.js\\");/* tests/out/vite-svelte/src/App.svelte generated by Svelte v3.48.0 */
"import { createHotContext as __vite__createHotContext } from \\"/vendor/vite-client.js\\";import.meta.hot = __vite__createHotContext(\\"/src/App.svelte.js\\");/* src/App.svelte generated by Svelte v3.48.0 */
import {
SvelteComponentDev as SvelteComponentDev$,
add_location as add_location$,
Expand Down Expand Up @@ -165,7 +165,7 @@ import {
const { Error: Error$, Object: Object$, console: console$ } = globals$;
import logo from '/src/assets/svelte.png__import.js';
import Counter from '/src/lib/Counter.svelte.js';
const file$ = \\"tests/out/vite-svelte/src/App.svelte\\";
const file$ = \\"src/App.svelte\\";
function create_fragment(ctx) {
let main$;
Expand Down Expand Up @@ -365,7 +365,7 @@ exports[`serve fs output > src/content.js-loader.js 1`] = `
`;
exports[`serve fs output > src/lib/Counter.svelte.js 1`] = `
"import { createHotContext as __vite__createHotContext } from \\"/vendor/vite-client.js\\";import.meta.hot = __vite__createHotContext(\\"/src/lib/Counter.svelte.js\\");/* tests/out/vite-svelte/src/lib/Counter.svelte generated by Svelte v3.48.0 */
"import { createHotContext as __vite__createHotContext } from \\"/vendor/vite-client.js\\";import.meta.hot = __vite__createHotContext(\\"/src/lib/Counter.svelte.js\\");/* src/lib/Counter.svelte generated by Svelte v3.48.0 */
import {
SvelteComponentDev as SvelteComponentDev$,
add_location as add_location$,
Expand All @@ -386,7 +386,7 @@ import {
} from \\"/vendor/svelte_internal.js__v--hash.js\\";
const { Error: Error$, Object: Object$, console: console$ } = globals$;
const file$ = \\"tests/out/vite-svelte/src/lib/Counter.svelte\\";
const file$ = \\"src/lib/Counter.svelte\\";
function create_fragment(ctx) {
let button$;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ do {
await new Promise((resolve) => setTimeout(resolve, timeout));
}
} while (!ready);
chrome.runtime.reload();
location.reload();
"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ do {
await new Promise((resolve) => setTimeout(resolve, timeout));
}
} while (!ready);
chrome.runtime.reload();
location.reload();
"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ do {
await new Promise((resolve) => setTimeout(resolve, timeout));
}
} while (!ready);
chrome.runtime.reload();
location.reload();
"
`;

Expand Down

0 comments on commit ce9fe1c

Please sign in to comment.