Skip to content

Commit

Permalink
chore: add playground
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Aug 14, 2024
1 parent 752828a commit 7dd0152
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 11 deletions.
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default config({
project: './tsconfig.tools.json',
},
},
},
{
files: ['src/**'],
rules: {
'unicorn/prefer-node-protocol': 'off',
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"picocolors": "^1.0.1",
"release-it": "^17.3.0",
"rollup": "^4.18.0",
"terser": "^5.31.6",
"typescript": "^5.4.5",
"unbuild": "^2.0.0",
"vite": "^5.2.12",
Expand Down
6 changes: 6 additions & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<script type="module" src="/main.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions playground/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert(import.meta.env.PROD ? 'PROD' : 'DEV')
6 changes: 6 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "vite-plugin-legacy-swc-playground",
"private": true,
"version": "0.0.0",
"type": "module"
}
14 changes: 14 additions & 0 deletions playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'
import legacy from '../src'

export default defineConfig({
root: path.dirname(fileURLToPath(import.meta.url)),
plugins: [
legacy({
targets: 'IE 11',
modernPolyfills: true,
}),
],
})
72 changes: 63 additions & 9 deletions pnpm-lock.yaml

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

11 changes: 11 additions & 0 deletions tests/playground.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { build } from 'vite'
import { expect, test } from 'vitest'

test('playground should work', async () => {
const res = await build({
root: path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../playground'),
})
expect(res).toBeTruthy()
})
4 changes: 2 additions & 2 deletions tests/readme.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs'
import path from 'path'
import fs from 'node:fs'
import path from 'node:path'
import { expect, test } from 'vitest'
import { cspHashes } from '../src'

Expand Down

0 comments on commit 7dd0152

Please sign in to comment.