Skip to content

Commit

Permalink
fix: npm run build
Browse files Browse the repository at this point in the history
  • Loading branch information
rudy-6-4 committed Feb 19, 2025
1 parent 9d99291 commit 3717a86
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ export default [
],
},
{
input: `./node_modules/tfhe/snippets/${wasmBindgenRayon}/src/workerHelpers.worker.js`,
input: `./node_modules/tfhe/snippets/${wasmBindgenRayon}/src/workerHelpers.js`,
output: {
file: 'lib/workerHelpers.worker.js',
file: 'lib/workerHelpers.js',
inlineDynamicImports: true,
name: 'worker',
format: 'esm',
},
Expand Down
2 changes: 1 addition & 1 deletion config/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default defineConfig({
],
worker: {
format: 'iife',
plugins: [ignoreURL(basePath)],
plugins: () => [ignoreURL(basePath)],
rollupOptions: {
output: {
entryFileNames: '[name].js',
Expand Down
6 changes: 3 additions & 3 deletions config/vite.replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ export const changeLoadingWorker = (basePath) => ({
// Only apply transformations to .js files (or other specific conditions)
if (id.endsWith('.js')) {
const searchValue =
/const worker = new Worker\(\s*new URL\(['"]\.?\/?workerHelpers\.worker\.js['"],\s*import\.meta\.url\),\s*\{\s*type:\s*'module',?\s*\},?\s*\);/;
/const worker = new Worker\(\s*new URL\(['"]\.?\/?workerHelpers.js['"],\s*import\.meta\.url\),\s*\{\s*type:\s*'module',?\s*\},?\s*\);/;

const replacement = `let worker;
try {
worker = new Worker(
new URL('./workerHelpers.worker.js', import.meta.url),
new URL('./workerHelpers.js', import.meta.url),
{
type: 'module'
}
);
} catch (e) {
const r = await fetch('${basePath}workerHelpers.worker.js');
const r = await fetch('${basePath}workerHelpers.js');
const blob = await r.blob();
const blobUrl = URL.createObjectURL(blob);
worker = new Worker(blobUrl);
Expand Down

0 comments on commit 3717a86

Please sign in to comment.