Skip to content

Commit

Permalink
test: error in worker test (#7518)
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Mar 30, 2022
1 parent a0f82bd commit b1db232
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
3 changes: 2 additions & 1 deletion packages/playground/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import fs from 'fs'
import path from 'path'
import colors from 'css-color-names'
import type { ElementHandle } from 'playwright-chromium'
import { Manifest, normalizePath } from 'vite'
import type { Manifest } from 'vite'
import { normalizePath } from 'vite'
import { fromComment } from 'convert-source-map'

export function slash(p: string): string {
Expand Down
1 change: 1 addition & 0 deletions packages/playground/worker/__tests__/iife/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../vite.config')
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'
import { untilUpdated, isBuild, testDir } from '../../testUtils'
import { untilUpdated, isBuild, testDir } from '../../../testUtils'
import type { Page } from 'playwright-chromium'

test('normal', async () => {
Expand Down Expand Up @@ -94,13 +94,3 @@ test('classic worker', async () => {
expect(await page.textContent('.classic-worker')).toMatch('A classic')
expect(await page.textContent('.classic-shared-worker')).toMatch('A classic')
})

function getSourceMapUrl(code: string): string {
const regex = /\/\/[#@]\s(?:source(?:Mapping)?URL)=\s*(\S+)/g
const results = regex.exec(code)

if (results && results.length >= 2) {
return results[1]
}
return null
}
9 changes: 9 additions & 0 deletions packages/playground/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"dev:es": "vite --config ./vite.config-es.js dev",
"build:es": "vite --config ./vite.config-es.js build",
"preview:es": "vite --config ./vite.config-es.js preview",
"dev:sourcemap": "cross-env WORKER_MODE=sourcemap vite --config ./vite.config-sourcemap.js dev",
"build:sourcemap": "cross-env WORKER_MODE=sourcemap vite --config ./vite.config-sourcemap.js build",
"preview:sourcemap": "cross-env WORKER_MODE=sourcemap vite --config ./vite.config-sourcemap.js preview",
"dev:sourcemap-hidden": "cross-env WORKER_MODE=hidden vite --config ./vite.config-sourcemap.js dev",
"build:sourcemap-hidden": "cross-env WORKER_MODE=hidden vite --config ./vite.config-sourcemap.js build",
"preview:sourcemap-hidden": "cross-env WORKER_MODE=hidden vite --config ./vite.config-sourcemap.js preview",
"dev:sourcemap-inline": "cross-env WORKER_MODE=inline vite --config ./vite.config-sourcemap.js dev",
"build:sourcemap-inline": "cross-env WORKER_MODE=inline vite --config ./vite.config-sourcemap.js build",
"preview:sourcemap-inline": "cross-env WORKER_MODE=inline vite --config ./vite.config-sourcemap.js preview",
"debug": "node --inspect-brk ../../vite/bin/vite"
},
"devDependencies": {
Expand Down
11 changes: 8 additions & 3 deletions packages/playground/worker/vite.config-sourcemap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const vueJsx = require('@vitejs/plugin-vue-jsx')
const vite = require('vite')

module.exports = (sourcemap) =>
vite.defineConfig({
module.exports = vite.defineConfig((sourcemap) => {
sourcemap = process.env.WORKER_MODE || sourcemap
if (sourcemap === 'sourcemap') {
sourcemap = true
}
return {
base: `/iife-${
typeof sourcemap === 'boolean' ? 'sourcemap' : 'sourcemap-' + sourcemap
}/`,
Expand All @@ -16,4 +20,5 @@ module.exports = (sourcemap) =>
}/`,
sourcemap: sourcemap
}
})
}
})

0 comments on commit b1db232

Please sign in to comment.