Skip to content

Commit

Permalink
test: migrate playgrounds to type: module
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed May 4, 2023
1 parent 9041e19 commit 1e50e23
Show file tree
Hide file tree
Showing 96 changed files with 249 additions and 97 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,19 @@ module.exports = defineConfig({
'@typescript-eslint/no-empty-function': 'off',
},
},
{
files: ['playground/**'],
excludedFiles: [
'playground/ssr-resolve/**',
'playground/**/*{commonjs,cjs}*/**',
'playground/**/*{commonjs,cjs}*',
'playground/**/*dep*/**',
'playground/resolve/browser-module-field2/index.web.js',
],
rules: {
'import/no-commonjs': 'error',
},
},
{
files: [
'playground/tsconfig-json/**',
Expand Down
1 change: 1 addition & 0 deletions playground/alias/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-alias",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
7 changes: 7 additions & 0 deletions playground/alias/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import path from 'node:path'
import url from 'node:url'
import module from 'node:module'
import { defineConfig } from 'vite'

const __filename = url.fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const require = module.createRequire(import.meta.url)

export default defineConfig({
resolve: {
alias: [
Expand Down
1 change: 1 addition & 0 deletions playground/assets-sanitize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-assets-sanitize",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-assets",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
"dev": "vite",
Expand Down
1 change: 1 addition & 0 deletions playground/backend-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-backend-integration",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
8 changes: 7 additions & 1 deletion playground/backend-integration/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { fileURLToPath } from 'node:url'
import { dirname } from 'node:path'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

// postcss.config.js
module.exports = {
export default {
plugins: {
tailwindcss: { config: __dirname + '/tailwind.config.js' },
},
Expand Down
4 changes: 3 additions & 1 deletion playground/backend-integration/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
/** @type {import('tailwindcss').Config} */

export default {
content: [__dirname + '/frontend/**/*.{css,html,ts,js}'],
theme: {
extend: {},
Expand Down
1 change: 1 addition & 0 deletions playground/build-old/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-build-old",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-cli",
"private": true,
"version": "0.0.0",
"type": "commonjs",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
8 changes: 6 additions & 2 deletions playground/config/__tests__/load.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { resolve } from 'node:path'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { loadConfigFromFile } from 'vite'
import { expect, it } from 'vitest'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

it('loadConfigFromFile', async () => {
const { config } = await loadConfigFromFile(
{} as any,
Expand All @@ -20,7 +24,7 @@ it('loadConfigFromFile', async () => {
4,
],
],
"moduleCondition": "require condition",
"moduleCondition": "import condition",
}
`)
})
1 change: 1 addition & 0 deletions playground/config/packages/entry/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@vite/test-config-entry",
"type": "module",
"dependencies": {
"@vite/test-config-plugin-module-condition": "link:../plugin-module-condition"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@vite/test-config-plugin-module-condition",
"type": "module",
"exports": {
".": {
"types": "./index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions playground/config/packages/siblings/foo.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { partition } from 'lodash'
import lodash from 'lodash'

export const array = partition([1, 2, 3, 4], (n) => n % 2)
export const array = lodash.partition([1, 2, 3, 4], (n) => n % 2)
1 change: 1 addition & 0 deletions playground/config/packages/siblings/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@vite/test-config-sibling",
"type": "module",
"devDependencies": {
"@types/lodash": "^4.14.194",
"lodash": "^4.17.21"
Expand Down
1 change: 1 addition & 0 deletions playground/css-codesplit-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-css-codesplit-cjs",
"private": true,
"version": "0.0.0",
"type": "commonjs",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/css-codesplit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-css-codesplit",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/css-dynamic-import/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@vitejs/test-css-dynamic-import",
"private": true,
"type": "module",
"version": "0.0.0"
}
1 change: 1 addition & 0 deletions playground/css-sourcemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-css-sourcemap",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { createServer } from 'vite'
import { expect, test } from 'vitest'
import { getBgColor, getColor, isServe, page, ports } from '~utils'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

// Regression test for https://github.com/vitejs/vite/issues/4000
test.runIf(isServe)('postcss plugins in different dir', async () => {
const port = ports['css/postcss-plugins-different-dir']
Expand Down
1 change: 1 addition & 0 deletions playground/css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-css",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/css/postcss-caching/blue-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "blue-app",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
2 changes: 1 addition & 1 deletion playground/css/postcss-caching/blue-app/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
plugins: [replacePinkWithBlue],
}

Expand Down
1 change: 1 addition & 0 deletions playground/css/postcss-caching/green-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "green-app",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
2 changes: 1 addition & 1 deletion playground/css/postcss-caching/green-app/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
plugins: [replacePinkWithGreen],
}

Expand Down
15 changes: 8 additions & 7 deletions playground/css/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module.exports = {
plugins: [require('postcss-nested'), testDirDep, testSourceInput],
}
import fs from 'node:fs'
import path from 'node:path'
import glob from 'fast-glob'
import { normalizePath } from 'vite'
import postcssNested from 'postcss-nested'

const fs = require('node:fs')
const path = require('node:path')
const glob = require('fast-glob')
const { normalizePath } = require('vite')
export default {
plugins: [postcssNested, testDirDep, testSourceInput],
}

/**
* A plugin for testing the `dir-dependency` message handling.
Expand Down
1 change: 1 addition & 0 deletions playground/data-uri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-data-uri",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/define/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-define",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/dynamic-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-dynamic-import",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
4 changes: 2 additions & 2 deletions playground/dynamic-import/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'node:fs'
import path from 'node:path'
import vite from 'vite'
import { defineConfig } from 'vite'

export default vite.defineConfig({
export default defineConfig({
plugins: [
{
name: 'copy',
Expand Down
1 change: 1 addition & 0 deletions playground/env-nested/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-env-nested",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-env",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "VITE_INLINE=inline-serve vite",
"build": "VITE_INLINE=inline-build vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-extensions",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/external/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-external",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/fs-serve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-fs-serve",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite root",
"build": "vite build root",
Expand Down
1 change: 1 addition & 0 deletions playground/glob-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-import-context",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/hmr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-hmr",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
16 changes: 0 additions & 16 deletions playground/hmr/tsconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions playground/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-html",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/import-assertion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-import-assertion",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
1 change: 1 addition & 0 deletions playground/js-sourcemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@vitejs/test-js-sourcemap",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down

0 comments on commit 1e50e23

Please sign in to comment.