Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken worker urls in 3rd party modules (fix #10838) #16418

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ import {
transformWithEsbuild,
} from '../plugins/esbuild'
import { ESBUILD_MODULES_TARGET, METADATA_FILENAME } from '../constants'
import { isWindows } from '../../shared/utils'
import { cleanUrl, isWindows } from '../../shared/utils'
import { type InternalResolveOptions, tryFsResolve } from '../plugins/resolve'
import { esbuildCjsExternalPlugin, esbuildDepPlugin } from './esbuildDepPlugin'
import { scanImports } from './scan'
import { createOptimizeDepsIncludeResolver, expandGlobIds } from './resolve'
import { getDepsOptimizer } from './optimizer'
export {
initDepsOptimizer,
initDevSsrDepsOptimizer,
Expand Down Expand Up @@ -1350,3 +1352,25 @@ const safeRename = promisify(function gracefulRename(
if (cb) cb(er)
})
})

export function tryOptimizedDepResolve(
config: ResolvedConfig,
ssr: boolean,
url: string,
depId: string,
fsResolveOptions: InternalResolveOptions,
): string | undefined {
const depsOptimizer = getDepsOptimizer(config, ssr)

if (depsOptimizer?.isOptimizedDepFile(depId)) {
const depFile = cleanUrl(depId)
const info = optimizedDepInfoFromFile(depsOptimizer.metadata, depFile)
const depSrc = info?.src
if (depSrc) {
const resolvedFile = path.resolve(path.dirname(depSrc), url)
Comment on lines +1367 to +1370
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it took me a while to review this.

IIUC this code assumes the optimized file and the original file to be a 1-to-1 mapping. But that isn't true. For example, if a dependency has multiple files, it becomes a single file.

When multiple file gets bundled in a single file, we need sourcemaps (or something that includes that kind of information) to identify which file the line was defined in.

I can think of 3 ways to fix this:

  1. Load the sourcemap in optimizedDepsPlugin's load hook and call getCombinedSourcemap in assetImportMetaUrlPlugin and use that to map to the original file
    • the downside of this is that when other plugins modify the sourcemap incorrectly, the generated code will be incorrect
  2. Save a modified optimized file when optimizing so that assetImportMetaUrlPlugin can resolve it correctly (like I tried to do in feat(optimizer): support import.meta.url #13501)
    • the downside of this is that the optimize logic becomes more complicated
  3. Modify the optimized file in optimizedDepsPlugin's load hook so that assetImportMetaUrlPlugin can resolve it correctly
    • the downside of this is that there will be a overhead of running the transformation every time the server starts

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this code assumes the optimized file and the original file to be a 1-to-1 mapping. But that isn't true. For example, if a dependency has multiple files, it becomes a single file.

I was thinking this a bit through and that's indeed tricky. Can you assist spinning up a failing test showing your exact concern? I'm not so deep into how splitting/merging might happen into Vite and keep mixing up things in my head on where we'd need to handle things differently.

My thoughts:

  • According to the rollup docs the ids we get into the transform hook are referring to a single module which is transformed.
  • In dev mode we seem to always get URLs pointing to individual dependency files e.g. in a react app referencing my library I get something like D:/Dev/myproject/src/node_modules/.vite/deps/@coderline_alphatab.js?v=9f8947bd
    • These IDs originate from the dependencies loaded before bundling.
      • addOptimizedDepInfo is called with these IDs from via this section
    • In dev-time the invidiual files of the dependencies are seemingly not bundled yet but served individually via .vite/deps/ urls.
  • In build mode I get the real file path D:/Dev/myproject/src/vite-react/node_modules/@coderline/alphatab/dist/alphaTab.mjs
    • Looking at the output there is afterwards only a "index.js" bundle with all 3rd party modules and the app code bundled.
  • I generally assume any bundling/splitting should already be handled by Vite and Rollup correctly as things should be correct for any main application files.
    • For main application files:
      • If files are not bundled, the modules are resolved via tryFsResolve correctly and from there we can find the worker/asset with the relative paths.
      • If files are bundled/chunked, Vite needs to generate certain files (optimized deps area?). But I'm not sure how in this case the existing code would already work.
    • For 3rd party files:
      • If they are not bundled, we newly as a fallback try go back into node_modules and try to resolve the asset/worker relatively to there. This is what this PR is trying to achieve.
      • If they are bundled/chunked we'd need to handle things more complex. Similarly to the main application file bundling I'm not sure how this would look like.

My questions:

  • Trying to improve things step-by-step: Can we somehow detect the 1:1 and allow this path. and 1:n/n:1 cases and for now show a warning of the 1:n/n:1 cases not being supported.
  • How would we reach the 1:n/n:1 path? In none of the frameworks or tests I was doing (dev/build) I managed to hit a path where bundling/chunking happened before this transform path was executed.
    • For the main file importing the worker/asset: Is there a stage where the 3rd party modules are bundled/split before being transformed and where is the related information available?
    • Is the optimizedDepInfoFromFile misleading and we need to loop through all matches as 'candidates' for valid paths? (not just pick the first one)
  • The existing code also mainly handles 1:1 scenarios, I wonder where the 1:n/n:1 logic is placed (other plugins doing additional rewrites?).

Copy link
Member

@sapphi-red sapphi-red Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you assist spinning up a failing test showing your exact concern?

Sure. I pushed a commit that updates the test that shows my concern: "For example, if a dependency has multiple files, it becomes a single file."

I'm not so deep into how splitting/merging might happen into Vite ...

To clarify, the splitting/merging happens by the optimizer. Vite uses esbuild's bundle feature to bundle some dependencies and pass the bundled dependencies to the plugin pipeline (the plugin pipeline is similar to rollup). new URL(, import.meta.url) becomes invalid after the optimization (esbuild's bundling) because the optimizer outputs the dependency into a different directory and also merges the files. Note that esbuild doesn't rewrite import.meta.url (evanw/esbuild#1492).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks. I'll look into getting this test green.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sapphi-red I debugged into this part and I think I understand things better now. Seems that the OptimizedDepInfo.src is a bit a (historical?) design flaw.

image

To keep the a good separation of concerns, multiple adaptions would be good:

  1. During bundling any relative URLs in the format of new URL('<relative path>', import.meta.url) have to be adjusted to be correct according to the bundle. (similar to your change).
    • We don't know what the plugins want to do with this URL, we should ensure that the URLs point to the correct path so that the bundle really represents a "semantic merge" not a "copy merge" of the files. Even if no plugin (assets/worker) would be active, the URLs should be correct after bundling.
    • It should not be the duty of every plugin to extract and correct the URLs. Whether bundled or not, the plugins should be able to focus on resolving paths to assets/workers relative to the given OptimizedDepInfo.src
  2. The changes of this PR would likely still be needed after (1). There is still quite a difference between optimized and unoptimized/physical deps as optimized deps need to still resolve assets relative to their origin.

What do you think about this solution design? This would allow us to merge this PR as part of (2) and focus about the bundling/optimization in a separate independent PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go with 2 or 3 in #16418 (comment), then we don't need this PR's change because the plugins won't need to change the way to resolve new URL(, import.meta.url). If we go with 1 in #16418 (comment), then we'll need a change like this PR but it won't use OptimizedDepInfo.src and I imagine the code will be quite different.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on how the transformed/corrected URL would look like whether this PR is needed or not. See this comparison:

Before Bundling

playground/assets/dep-with-asset/index.js

export { imageUrl } from './dir/path.js'
export const imageUrlRoot = new URL('./asset.png', import.meta.url).href;

playground/assets/dep-with-asset/dir/path.js

export const imageUrl = new URL('../asset.png, import.meta.url).href;

After Bundling (my current thinking)

The URLs are adjusted to stay relative urls within the dependency just as-if the package would deliver the bundle itself.

Pro:

  • This way we follow more a "relative URL" instead of a "relative file path" approach.
  • The bundler doesn't work in a way to serve the specific plugins for assets and workers. It is the concern of the asset & worker plugins that the URLs point to a physical file in the package and we need to adjust the paths so that the physical files are copied and served.
  • It feels less invasive. If the package would ship a bundle itself, it would look also like this.

Con:

  • The physical paths are not correct for the worker and asset plugin. They (and other plugins) need to resolve the source of the dependency bundle if the URL points to a physical file (this PR).

/playground/assets/node_modules/.vite/deps/@vitejs_test-dep-with-asset.js?v=1cdbd667

// ../../node_modules/.pnpm/@vitejs+test-dep-with-asset@file+playground+assets+dep-with-asset/node_modules/@vitejs/test-dep-with-asset/dir/path.js
var imageUrl = new URL("./asset.png", import.meta.url).href;

// ../../node_modules/.pnpm/@vitejs+test-dep-with-asset@file+playground+assets+dep-with-asset/node_modules/@vitejs/test-dep-with-asset/index.js
var imageUrlRoot = new URL("./asset.png", import.meta.url).href;
export {
  imageUrl,
  imageUrlRoot
};
//# sourceMappingURL=@vitejs_test-dep-with-asset.js.map

After Bundling (my understanding of your approach)

The URLs are adjusted to relative (or absolute?) file paths on disk.

Pro:

  • URLs will point to the correct file paths after bundling (relative to the bundle) allowing easy resolving of paths in worker and asset plugins.

Con:

  • Another plugins MUST pickup these URLs and ensure they are further transformed and served. Otherwise URLs might attempt to reach beyond the root path pointing to a path which might not be served new URL('../../../../../node_modules/@depscope/dep/subpath/test.html', import.meta.url).href where import.meta.url=http://localhost/app.js
  • If 3rd party plugins want to do a custom URL logic not based on file paths they have to "undo" the bundler path logic.

Code:
/playground/assets/node_modules/.vite/deps/@vitejs_test-dep-with-asset.js?v=1cdbd667

// ../../node_modules/.pnpm/@vitejs+test-dep-with-asset@file+playground+assets+dep-with-asset/node_modules/@vitejs/test-dep-with-asset/dir/path.js
var imageUrl = new URL("../../../../../node_modules/.pnpm/@vitejs+test-dep-with-asset@file+playground+assets+dep-with-asset/node_modules/@vitejs/test-dep-with-asset/asset.png", import.meta.url).href;

// ../../node_modules/.pnpm/@vitejs+test-dep-with-asset@file+playground+assets+dep-with-asset/node_modules/@vitejs/test-dep-with-asset/index.js
var imageUrlRoot = new Url("../../../../../node_modules/.pnpm/@vitejs+test-dep-with-asset@file+playground+assets+dep-with-asset/node_modules/@vitejs/test-dep-with-asset/asset.png", import.meta.url).href;
export {
  imageUrl,
  imageUrlRoot
};
//# sourceMappingURL=@vitejs_test-dep-with-asset.js.map

For my own needs I am fine with either approach. For my needs even only this PR is enough.

I am only a bit worried about unexpected side effects of the bundler rewriting too much requiring us to revert the change again. A configuration option (magic comments / vite.config with regexp patterns) to control the behavior could reduce the risk at cost of complexity in Vite delivering correct results in all combinations.

As owners of Vite its your call for decision. I'd be happy to give either one a try to implement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this PR in today's team meeting.

We think this issue is better solved at esbuild level (or Rolldown level after we start using it) and would benefit more people. So we suggest helping esbuild supporting this feature (evanw/esbuild#2508). For example, providing a test case.

But if you would like to work on the fix on Vite side, we are open to having a fix on Vite side in the way 2 or 3 in #16418 (comment). It was mentioned in the meeting that onEnd might also be useful. But if the implementation is complex, we might not merge the PR. Even if the PR is merged, we would partially or fully revert the PR in the near future when we start using Rolldown in Vite for the optimizer.

return tryFsResolve(resolvedFile, fsResolveOptions)
}
}

return undefined
}
12 changes: 11 additions & 1 deletion packages/vite/src/node/plugins/assetImportMetaUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { ResolveFn } from '../'
import { injectQuery, isParentDirectory, transformStableResult } from '../utils'
import { CLIENT_ENTRY } from '../constants'
import { slash } from '../../shared/utils'
import { tryOptimizedDepResolve } from '../optimizer'
import { fileToUrl } from './asset'
import { preloadHelperId } from './importAnalysisBuild'
import type { InternalResolveOptions } from './resolve'
Expand Down Expand Up @@ -104,7 +105,16 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
let file: string | undefined
if (url[0] === '.') {
file = slash(path.resolve(path.dirname(id), url))
file = tryFsResolve(file, fsResolveOptions) ?? file
file =
tryFsResolve(file, fsResolveOptions) ??
tryOptimizedDepResolve(
config,
options?.ssr === true,
url,
id,
fsResolveOptions,
) ??
file
} else {
assetResolver ??= config.createResolver({
extensions: [],
Expand Down
13 changes: 12 additions & 1 deletion packages/vite/src/node/plugins/workerImportMetaUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Plugin } from '../plugin'
import { evalValue, injectQuery, transformStableResult } from '../utils'
import type { ResolveFn } from '..'
import { cleanUrl, slash } from '../../shared/utils'
import { tryOptimizedDepResolve } from '../optimizer'
import type { WorkerType } from './worker'
import { WORKER_FILE_ID, workerFileToUrl } from './worker'
import { fileToUrl } from './asset'
Expand Down Expand Up @@ -148,10 +149,20 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
s ||= new MagicString(code)
const workerType = getWorkerType(code, cleanString, endIndex)
const url = rawUrl.slice(1, -1)

let file: string | undefined
if (url[0] === '.') {
file = path.resolve(path.dirname(id), url)
file = tryFsResolve(file, fsResolveOptions) ?? file
file =
tryFsResolve(file, fsResolveOptions) ??
tryOptimizedDepResolve(
config,
options?.ssr === true,
url,
id,
fsResolveOptions,
) ??
file
} else {
workerResolver ??= config.createResolver({
extensions: [],
Expand Down
11 changes: 11 additions & 0 deletions playground/assets/__tests__/assets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,3 +570,14 @@ test.runIf(isBuild)('assets inside <noscript> is rewrote', async () => {
/<img class="noscript" src="\/foo\/bar\/assets\/asset-[-\w]+\.png" \/>/,
)
})

test('import.meta.url in dependency', async () => {
const match = isBuild
? /\/foo\/bar\/assets\/asset-[-\w]{8}\.png/
: /node_modules\/@vitejs\/test-dep-with-asset\/asset.png/

expect(await page.textContent('.import-meta-url-dependency')).toMatch(match)
expect(
await page.getAttribute('.import-meta-url-img-dependency', 'src'),
).toMatch(match)
})
Binary file added playground/assets/dep-with-asset/asset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions playground/assets/dep-with-asset/dir/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const imageUrl = new URL('../asset.png', import.meta.url).href
1 change: 1 addition & 0 deletions playground/assets/dep-with-asset/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { imageUrl } from './dir/path.js'
7 changes: 7 additions & 0 deletions playground/assets/dep-with-asset/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@vitejs/test-dep-with-asset",
"private": true,
"version": "1.0.0",
"type": "module",
"main": "index.js"
}
9 changes: 9 additions & 0 deletions playground/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -578,3 +578,12 @@ <h3>assets in noscript</h3>
document.querySelector(el).textContent = text
}
</script>

<h2>import.meta.url in dependency</h2>
<img class="import-meta-url-img-dependency" />
<code class="import-meta-url-dependency"></code>
<script type="module">
import { imageUrl } from '@vitejs/test-dep-with-asset'
text('.import-meta-url-dependency', imageUrl)
document.querySelector('.import-meta-url-img-dependency').src = imageUrl
</script>
3 changes: 3 additions & 0 deletions playground/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"dev:url-base": "vite --config ./vite.config-url-base.js dev",
"build:url-base": "vite --config ./vite.config-url-base.js build",
"preview:url-base": "vite --config ./vite.config-url-base.js preview"
},
"dependencies": {
"@vitejs/test-dep-with-asset": "file:./dep-with-asset"
}
}
1 change: 0 additions & 1 deletion playground/optimize-deps/dep-incompatible/sub.js

This file was deleted.

10 changes: 9 additions & 1 deletion playground/worker/__tests__/es/worker-es.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe.runIf(isBuild)('build', () => {
test('inlined code generation', async () => {
const assetsDir = path.resolve(testDir, 'dist/es/assets')
const files = fs.readdirSync(assetsDir)
expect(files.length).toBe(34)
expect(files.length).toBe(35)
const index = files.find((f) => f.includes('main-module'))
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
const worker = files.find((f) => f.includes('my-worker'))
Expand Down Expand Up @@ -240,3 +240,11 @@ test('self reference url worker', async () => {
'pong: main\npong: nested\n',
)
})

test('dep with worker', async () => {
await untilUpdated(
() => page.textContent('.dep-with-worker'),
'entry: main\nentry: worker\npong: worker',
true,
)
})
8 changes: 7 additions & 1 deletion playground/worker/__tests__/iife/worker-iife.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe.runIf(isBuild)('build', () => {
test('inlined code generation', async () => {
const assetsDir = path.resolve(testDir, 'dist/iife/assets')
const files = fs.readdirSync(assetsDir)
expect(files.length).toBe(22)
expect(files.length).toBe(23)
const index = files.find((f) => f.includes('main-module'))
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
const worker = files.find((f) => f.includes('worker_entry-my-worker'))
Expand Down Expand Up @@ -192,3 +192,9 @@ function decodeSourceMapUrl(content: string) {
).toString(),
)
}

test('dep with worker', async () => {
expectWithRetry(() => page.textContent('.dep-with-worker')).toBe(
'ping: main\npong: worker',
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,9 @@ test('self reference url worker', async () => {
'pong: main\npong: nested\n',
)
})

test('dep with worker', async () => {
expectWithRetry(() => page.textContent('.dep-with-worker')).toBe(
'ping: main\npong: worker',
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe.runIf(isBuild)('build', () => {

const files = fs.readdirSync(assetsDir)
// should have 2 worker chunk
expect(files.length).toBe(44)
expect(files.length).toBe(46)
const index = files.find((f) => f.includes('main-module'))
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
const indexSourcemap = getSourceMapUrl(content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe.runIf(isBuild)('build', () => {

const files = fs.readdirSync(assetsDir)
// should have 2 worker chunk
expect(files.length).toBe(22)
expect(files.length).toBe(23)
const index = files.find((f) => f.includes('main-module'))
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
const indexSourcemap = getSourceMapUrl(content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe.runIf(isBuild)('build', () => {
const assetsDir = path.resolve(testDir, 'dist/iife-sourcemap/assets')
const files = fs.readdirSync(assetsDir)
// should have 2 worker chunk
expect(files.length).toBe(44)
expect(files.length).toBe(46)
const index = files.find((f) => f.includes('main-module'))
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
const indexSourcemap = getSourceMapUrl(content)
Expand Down
7 changes: 7 additions & 0 deletions playground/worker/dep-with-worker/dep-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { sharedBetweenWorkerAndMain } from './shared'

self.onmessage = (e) => {
self.postMessage(e.data)
}

sharedBetweenWorkerAndMain('', 'entry: worker')
17 changes: 17 additions & 0 deletions playground/worker/dep-with-worker/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { sharedBetweenWorkerAndMain } from './shared.js'

export function startWorker(el) {
sharedBetweenWorkerAndMain(el, 'entry: main')

const worker = new Worker(
new URL('./dep-worker.js?worker', import.meta.url),
{
type: 'module',
},
)
worker.addEventListener('message', (e) => {
console.log('message', e)
sharedBetweenWorkerAndMain(el, e.data.msg)
})
worker.postMessage({ msg: 'pong: worker' })
}
7 changes: 7 additions & 0 deletions playground/worker/dep-with-worker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@vitejs/test-dep-with-worker",
"private": true,
"version": "1.0.0",
"type": "module",
"main": "index.js"
}
9 changes: 9 additions & 0 deletions playground/worker/dep-with-worker/shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function sharedBetweenWorkerAndMain(el, text) {
if ('WorkerGlobalScope' in globalThis) {
self.postMessage({ msg: text })
} else if (document.querySelector(el).textContent.length > 0) {
document.querySelector(el).textContent += '\n' + text
} else {
document.querySelector(el).textContent = text
}
}
6 changes: 6 additions & 0 deletions playground/worker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ <h2 class="format-es"></h2>
</p>
<code class="module-and-worker-worker"></code>

<p>
worker within dependency
<span class="classname">.dep-with-worker</span>
</p>
<code class="dep-with-worker"></code>

<style>
p {
background: rgba(0, 0, 0, 0.1);
Expand Down
3 changes: 2 additions & 1 deletion playground/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"debug": "node --inspect-brk ../../packages/vite/bin/vite"
},
"dependencies": {
"@vitejs/test-dep-to-optimize": "file:./dep-to-optimize"
"@vitejs/test-dep-to-optimize": "file:./dep-to-optimize",
"@vitejs/test-dep-with-worker": "file:./dep-with-worker"
}
}
3 changes: 3 additions & 0 deletions playground/worker/worker/main-module.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { startWorker as startDepWorker } from '@vitejs/test-dep-with-worker'
import myWorker from '../my-worker.ts?worker'
import InlineWorker from '../my-worker.ts?worker&inline'
import InlineSharedWorker from '../my-inline-shared-worker?sharedworker&inline'
Expand Down Expand Up @@ -174,3 +175,5 @@ selfReferenceUrlWorker.addEventListener('message', (e) => {
document.querySelector('.self-reference-url-worker').textContent +=
`${e.data}\n`
})

startDepWorker('.dep-with-worker')
23 changes: 22 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading