mirror of
https://github.com/vitejs/vite.git
synced 2024-11-22 07:09:05 +00:00
test: error in worker test (#7518)
This commit is contained in:
parent
a0f82bd88c
commit
b1db2326a8
@ -6,7 +6,8 @@ import fs from 'fs'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import colors from 'css-color-names'
|
import colors from 'css-color-names'
|
||||||
import type { ElementHandle } from 'playwright-chromium'
|
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'
|
import { fromComment } from 'convert-source-map'
|
||||||
|
|
||||||
export function slash(p: string): string {
|
export function slash(p: string): string {
|
||||||
|
1
packages/playground/worker/__tests__/iife/vite.config.js
Normal file
1
packages/playground/worker/__tests__/iife/vite.config.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = require('../../vite.config')
|
@ -1,6 +1,6 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { untilUpdated, isBuild, testDir } from '../../testUtils'
|
import { untilUpdated, isBuild, testDir } from '../../../testUtils'
|
||||||
import type { Page } from 'playwright-chromium'
|
import type { Page } from 'playwright-chromium'
|
||||||
|
|
||||||
test('normal', async () => {
|
test('normal', async () => {
|
||||||
@ -94,13 +94,3 @@ test('classic worker', async () => {
|
|||||||
expect(await page.textContent('.classic-worker')).toMatch('A classic')
|
expect(await page.textContent('.classic-worker')).toMatch('A classic')
|
||||||
expect(await page.textContent('.classic-shared-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,6 +9,15 @@
|
|||||||
"dev:es": "vite --config ./vite.config-es.js dev",
|
"dev:es": "vite --config ./vite.config-es.js dev",
|
||||||
"build:es": "vite --config ./vite.config-es.js build",
|
"build:es": "vite --config ./vite.config-es.js build",
|
||||||
"preview:es": "vite --config ./vite.config-es.js preview",
|
"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"
|
"debug": "node --inspect-brk ../../vite/bin/vite"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
const vueJsx = require('@vitejs/plugin-vue-jsx')
|
const vueJsx = require('@vitejs/plugin-vue-jsx')
|
||||||
const vite = require('vite')
|
const vite = require('vite')
|
||||||
|
|
||||||
module.exports = (sourcemap) =>
|
module.exports = vite.defineConfig((sourcemap) => {
|
||||||
vite.defineConfig({
|
sourcemap = process.env.WORKER_MODE || sourcemap
|
||||||
|
if (sourcemap === 'sourcemap') {
|
||||||
|
sourcemap = true
|
||||||
|
}
|
||||||
|
return {
|
||||||
base: `/iife-${
|
base: `/iife-${
|
||||||
typeof sourcemap === 'boolean' ? 'sourcemap' : 'sourcemap-' + sourcemap
|
typeof sourcemap === 'boolean' ? 'sourcemap' : 'sourcemap-' + sourcemap
|
||||||
}/`,
|
}/`,
|
||||||
@ -16,4 +20,5 @@ module.exports = (sourcemap) =>
|
|||||||
}/`,
|
}/`,
|
||||||
sourcemap: sourcemap
|
sourcemap: sourcemap
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user