Skip to content

Commit

Permalink
test: remove jsx plugin from worker playground (#11177)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Dec 6, 2022
1 parent 014e4aa commit 51ceb4e
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 156 deletions.
2 changes: 1 addition & 1 deletion playground/worker/__tests__/es/es-worker.spec.ts
Expand Up @@ -57,7 +57,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(27)
expect(files.length).toBe(28)
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
1 change: 1 addition & 0 deletions playground/worker/modules/test-plugin.js
@@ -0,0 +1 @@
export const bundleWithPlugin = 'worker bundle with plugin fail. '
1 change: 0 additions & 1 deletion playground/worker/modules/test-plugin.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions playground/worker/package.json
Expand Up @@ -25,8 +25,5 @@
},
"dependencies": {
"@vitejs/test-dep-to-optimize": "file:./dep-to-optimize"
},
"devDependencies": {
"@vitejs/plugin-vue-jsx": "^3.0.0-alpha.0"
}
}
5 changes: 3 additions & 2 deletions playground/worker/vite.config-es.js
@@ -1,5 +1,5 @@
const vueJsx = require('@vitejs/plugin-vue-jsx')
const vite = require('vite')
const workerPluginTestPlugin = require('./worker-plugin-test-plugin')

module.exports = vite.defineConfig({
base: '/es/',
Expand All @@ -11,7 +11,7 @@ module.exports = vite.defineConfig({
},
worker: {
format: 'es',
plugins: [vueJsx()],
plugins: [workerPluginTestPlugin()],
rollupOptions: {
output: {
assetFileNames: 'assets/worker_asset-[name].[ext]',
Expand All @@ -31,6 +31,7 @@ module.exports = vite.defineConfig({
},
},
plugins: [
workerPluginTestPlugin(),
{
name: 'resolve-format-es',

Expand Down
5 changes: 3 additions & 2 deletions playground/worker/vite.config-iife.js
@@ -1,5 +1,5 @@
const vueJsx = require('@vitejs/plugin-vue-jsx')
const vite = require('vite')
const workerPluginTestPlugin = require('./worker-plugin-test-plugin')

module.exports = vite.defineConfig({
base: '/iife/',
Expand All @@ -11,7 +11,7 @@ module.exports = vite.defineConfig({
worker: {
format: 'iife',
plugins: [
vueJsx(),
workerPluginTestPlugin(),
{
name: 'config-test',
config() {
Expand Down Expand Up @@ -46,4 +46,5 @@ module.exports = vite.defineConfig({
},
},
},
plugins: [workerPluginTestPlugin()],
})
5 changes: 3 additions & 2 deletions playground/worker/vite.config-relative-base.js
@@ -1,6 +1,6 @@
const path = require('node:path')
const vueJsx = require('@vitejs/plugin-vue-jsx')
const vite = require('vite')
const workerPluginTestPlugin = require('./worker-plugin-test-plugin')

module.exports = vite.defineConfig({
base: './',
Expand All @@ -11,7 +11,7 @@ module.exports = vite.defineConfig({
},
worker: {
format: 'es',
plugins: [vueJsx()],
plugins: [workerPluginTestPlugin()],
rollupOptions: {
output: {
assetFileNames: 'worker-assets/worker_asset-[name]-[hash].[ext]',
Expand All @@ -34,6 +34,7 @@ module.exports = vite.defineConfig({
baseRoute: '/relative-base/',
},
plugins: [
workerPluginTestPlugin(),
{
name: 'resolve-format-es',
transform(code, id) {
Expand Down
5 changes: 3 additions & 2 deletions playground/worker/vite.config-sourcemap.js
@@ -1,5 +1,5 @@
const vueJsx = require('@vitejs/plugin-vue-jsx')
const vite = require('vite')
const workerPluginTestPlugin = require('./worker-plugin-test-plugin')

module.exports = vite.defineConfig((sourcemap) => {
sourcemap = process.env.WORKER_MODE || sourcemap
Expand All @@ -17,7 +17,7 @@ module.exports = vite.defineConfig((sourcemap) => {
},
worker: {
format: 'iife',
plugins: [vueJsx()],
plugins: [workerPluginTestPlugin()],
rollupOptions: {
output: {
assetFileNames: 'assets/[name]-worker_asset[hash].[ext]',
Expand All @@ -39,5 +39,6 @@ module.exports = vite.defineConfig((sourcemap) => {
},
},
},
plugins: [workerPluginTestPlugin()],
}
})
12 changes: 12 additions & 0 deletions playground/worker/worker-plugin-test-plugin.js
@@ -0,0 +1,12 @@
module.exports = () => ({
name: 'plugin-for-worker',
transform(code, id) {
if (id.includes('worker/modules/test-plugin.js')) {
return {
// keep length for sourcemap
code: code.replace('plugin fail. ', 'plugin success!'),
map: null,
}
}
},
})
143 changes: 0 additions & 143 deletions pnpm-lock.yaml

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

0 comments on commit 51ceb4e

Please sign in to comment.