Skip to content

Commit

Permalink
chore: 🤖 update
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY committed Aug 24, 2024
1 parent 0d783f9 commit 34919df
Show file tree
Hide file tree
Showing 46 changed files with 212 additions and 130 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
"typecheck": "tsc -p scripts --noEmit && pnpm -r --parallel run typecheck",
"test": "run-s test-serve test-build",
"test-serve": "vitest run -c vitest.config.e2e.ts",
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts --no-file-parallelism",
"test-unit": "vitest run",
"test-docs": "pnpm run docs-build",
"debug-serve": "VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts",
"debug-build": "VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts",
"debug-build": "VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts --no-file-parallelism",
"docs": "pnpm --filter=docs run docs",
"docs-build": "pnpm --filter=docs run docs-build",
"docs-serve": "pnpm --filter=docs run docs-serve",
Expand All @@ -40,7 +40,7 @@
"ci-docs": "run-s build docs-build"
},
"devDependencies": {
"@eslint/js": "^9.8.0",
"@eslint/js": "^9.9.0",
"@types/babel__core": "^7.20.5",
"@types/babel__preset-env": "^7.9.7",
"@types/convert-source-map": "^2.0.3",
Expand All @@ -50,31 +50,31 @@
"@types/etag": "^1.8.3",
"@types/less": "^3.0.6",
"@types/micromatch": "^4.0.9",
"@types/node": "^20.14.14",
"@types/picomatch": "^3.0.0",
"@types/node": "^20.16.1",
"@types/picomatch": "^3.0.1",
"@types/stylus": "^0.48.42",
"@types/ws": "^8.5.12",
"@vitejs/release-scripts": "^1.3.2",
"conventional-changelog-cli": "^5.0.0",
"eslint": "^9.8.0",
"eslint": "^9.9.0",
"eslint-plugin-import-x": "^3.1.0",
"eslint-plugin-n": "^17.10.2",
"eslint-plugin-regexp": "^2.6.0",
"execa": "^9.3.0",
"execa": "^9.3.1",
"globals": "^15.9.0",
"lint-staged": "^15.2.8",
"lint-staged": "^15.2.9",
"npm-run-all2": "^6.2.2",
"picocolors": "^1.0.1",
"playwright-chromium": "^1.45.3",
"playwright-chromium": "^1.46.1",
"prettier": "3.3.3",
"rimraf": "^5.0.10",
"rollup": "^4.13.0",
"rollup": "^4.20.0",
"rollup-plugin-esbuild": "^6.1.1",
"simple-git-hooks": "^2.11.1",
"tslib": "^2.6.3",
"tsx": "^4.16.5",
"tsx": "^4.17.0",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.0",
"typescript-eslint": "^8.1.0",
"vite": "workspace:*",
"vitest": "^2.0.5"
},
Expand All @@ -95,7 +95,7 @@
"eslint --cache --fix"
]
},
"packageManager": "pnpm@9.6.0",
"packageManager": "pnpm@9.7.1",
"pnpm": {
"overrides": {
"vite": "workspace:*"
Expand Down
4 changes: 2 additions & 2 deletions playground/alias/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
},
"dependencies": {
"aliased-module": "file:./dir/module",
"vue": "^3.4.35",
"@vue/shared": "^3.4.35"
"vue": "^3.4.38",
"@vue/shared": "^3.4.38"
},
"devDependencies": {
"@vitejs/test-resolve-linked": "workspace:*"
Expand Down
51 changes: 26 additions & 25 deletions playground/assets/__tests__/assets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,31 +500,32 @@ test.runIf(isBuild)('manifest', async () => {
}
})

describe.runIf(isBuild)('css and assets in css in build watch', () => {
test('css will not be lost and css does not contain undefined', async () => {
editFile('index.html', (code) => code.replace('Assets', 'assets'), true)
await notifyRebuildComplete(watcher)
const cssFile = findAssetFile(/index-[-\w]+\.css$/, 'foo')
expect(cssFile).not.toBe('')
expect(cssFile).not.toMatch(/undefined/)
})

test('import module.css', async () => {
expect(await getColor('#foo')).toBe('red')
editFile('css/foo.module.css', (code) => code.replace('red', 'blue'), true)
await notifyRebuildComplete(watcher)
await page.reload()
expect(await getColor('#foo')).toBe('blue')
})

test('import with raw query', async () => {
expect(await page.textContent('.raw-query')).toBe('foo')
editFile('static/foo.txt', (code) => code.replace('foo', 'zoo'), true)
await notifyRebuildComplete(watcher)
await page.reload()
expect(await page.textContent('.raw-query')).toBe('zoo')
})
})
// Rolldown not supported rebuild
// describe.runIf(isBuild)('css and assets in css in build watch', () => {
// test('css will not be lost and css does not contain undefined', async () => {
// editFile('index.html', (code) => code.replace('Assets', 'assets'), true)
// await notifyRebuildComplete(watcher)
// const cssFile = findAssetFile(/index-[-\w]+\.css$/, 'foo')
// expect(cssFile).not.toBe('')
// expect(cssFile).not.toMatch(/undefined/)
// })

// test('import module.css', async () => {
// expect(await getColor('#foo')).toBe('red')
// editFile('css/foo.module.css', (code) => code.replace('red', 'blue'), true)
// await notifyRebuildComplete(watcher)
// await page.reload()
// expect(await getColor('#foo')).toBe('blue')
// })

// test('import with raw query', async () => {
// expect(await page.textContent('.raw-query')).toBe('foo')
// editFile('static/foo.txt', (code) => code.replace('foo', 'zoo'), true)
// await notifyRebuildComplete(watcher)
// await page.reload()
// expect(await page.textContent('.raw-query')).toBe('zoo')
// })
// })

test('inline style test', async () => {
expect(await getBg('.inline-style')).toMatch(assetMatch)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, test } from 'vitest'
import { describe, expect, test, vi } from 'vitest'
import {
browserErrors,
browserLogs,
Expand All @@ -8,16 +8,13 @@ import {
isServe,
listAssets,
page,
ports,
readManifest,
serverLogs,
untilBrowserLogAfter,
untilUpdated,
} from '~utils'

const outerAssetMatch = isBuild
? /\/dev\/assets\/logo-[-\w]{8}\.png/
: /\/dev\/@fs\/.+?\/images\/logo\.png/

test('should have no 404s', () => {
browserLogs.forEach((msg) => {
expect(msg).not.toMatch('404')
Expand All @@ -26,9 +23,25 @@ test('should have no 404s', () => {

describe('asset imports from js', () => {
test('file outside root', async () => {
expect(
await page.textContent('.asset-reference.outside-root .asset-url'),
).toMatch(outerAssetMatch)
// assert valid image src https://github.com/microsoft/playwright/issues/6046#issuecomment-1799585719
await vi.waitUntil(() =>
page
.locator('.asset-reference.outside-root .asset-preview')
.evaluate((el: HTMLImageElement) => el.naturalWidth > 0),
)

const text = await page.textContent(
'.asset-reference.outside-root .asset-url',
)
if (isBuild) {
expect(text).toMatch(/\/dev\/assets\/logo-[-\w]{8}\.png/)
} else {
// asset url is prefixed with server.origin
expect(text).toMatch(
`http://localhost:${ports['backend-integration']}/dev/@fs/`,
)
expect(text).toMatch(/\/dev\/@fs\/.+?\/images\/logo\.png/)
}
})
})

Expand Down
2 changes: 1 addition & 1 deletion playground/backend-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"devDependencies": {
"sass": "^1.77.8",
"tailwindcss": "^3.4.7",
"tailwindcss": "^3.4.10",
"fast-glob": "^3.3.2"
}
}
9 changes: 9 additions & 0 deletions playground/backend-integration/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ function BackendIntegrationExample() {
entrypoints.push(['bar.css', path.resolve(__dirname, './dir/foo.css')])

return {
server: {
// same port in playground/test-utils.ts
port: 5009,
strictPort: true,
origin: 'http://localhost:5009',
},
preview: {
port: 5009,
},
build: {
manifest: true,
outDir,
Expand Down
2 changes: 1 addition & 1 deletion playground/css-lightningcss-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"devDependencies": {
"lightningcss": "^1.25.1",
"lightningcss": "^1.26.0",
"express": "^4.19.2"
}
}
2 changes: 1 addition & 1 deletion playground/css-lightningcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"preview": "vite preview"
},
"devDependencies": {
"lightningcss": "^1.25.1"
"lightningcss": "^1.26.0"
}
}
1 change: 1 addition & 0 deletions playground/css/__tests__/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ test('sass', async () => {
isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`,
)
expect(await getColor(partialImport)).toBe('orchid')
expect(await getColor(await page.$('.sass-file-absolute'))).toBe('orange')

editFile('sass.scss', (code) =>
code.replace('color: $injectedColor', 'color: red'),
Expand Down
3 changes: 3 additions & 0 deletions playground/css/file-absolute.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.sass-file-absolute {
color: orange;
}
3 changes: 3 additions & 0 deletions playground/css/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ <h1>CSS</h1>
<p class="sass-dep">
@import dependency w/ no scss entrypoint: this should be lavender
</p>
<p class="sass-file-absolute">
@import "file:///xxx/absolute-path.scss" should be orange
</p>

<p class="less">Less: This should be blue</p>
<p class="less-at-import">
Expand Down
1 change: 1 addition & 0 deletions playground/css/sass.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@import 'virtual-dep'; // virtual file added through importer
@import '=/pkg-dep'; // package w/out sass field
@import '=/weapp.wxss'; // wxss file
@import 'virtual-file-absolute';

.sass {
/* injected via vite.config.js */
Expand Down
19 changes: 2 additions & 17 deletions playground/css/vite.config-sass-modern-compiler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite'
import baseConfig from './vite.config.js'
import configSassModern from './vite.config-sass-modern.js'

export default defineConfig({
...baseConfig,
Expand All @@ -8,23 +9,7 @@ export default defineConfig({
preprocessorOptions: {
...baseConfig.css.preprocessorOptions,
scss: {
api: 'modern-compiler',
additionalData: `$injectedColor: orange;`,
importers: [
{
canonicalize(url) {
return url === 'virtual-dep'
? new URL('custom-importer:virtual-dep')
: null
},
load() {
return {
contents: ``,
syntax: 'scss',
}
},
},
],
...configSassModern.css.preprocessorOptions.scss,
},
},
},
Expand Down
15 changes: 15 additions & 0 deletions playground/css/vite.config-sass-modern.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { pathToFileURL } from 'node:url'
import path from 'node:path'
import { defineConfig } from 'vite'
import baseConfig from './vite.config.js'

Expand All @@ -24,6 +26,19 @@ export default defineConfig({
}
},
},
{
canonicalize(url) {
return url === 'virtual-file-absolute'
? new URL('custom-importer:virtual-file-absolute')
: null
},
load() {
return {
contents: `@import "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
syntax: 'scss',
}
},
},
],
},
},
Expand Down
8 changes: 8 additions & 0 deletions playground/css/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'node:path'
import { pathToFileURL } from 'node:url'
import stylus from 'stylus'
import { defineConfig } from 'vite'

Expand Down Expand Up @@ -65,6 +66,13 @@ export default defineConfig({
function (url) {
return url === 'virtual-dep' ? { contents: '' } : null
},
function (url) {
return url === 'virtual-file-absolute'
? {
contents: `@import "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
}
: null
},
function (url) {
return url.endsWith('.wxss') ? { contents: '' } : null
},
Expand Down
2 changes: 1 addition & 1 deletion playground/extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.4.35"
"vue": "^3.4.38"
}
}
2 changes: 1 addition & 1 deletion playground/external/dep-that-imports/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"dependencies": {
"slash3": "npm:slash@^3.0.0",
"slash5": "npm:slash@^5.1.0",
"vue": "^3.4.35"
"vue": "^3.4.38"
}
}
2 changes: 1 addition & 1 deletion playground/external/dep-that-requires/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"dependencies": {
"slash3": "npm:slash@^3.0.0",
"slash5": "npm:slash@^5.1.0",
"vue": "^3.4.35"
"vue": "^3.4.38"
}
}
2 changes: 1 addition & 1 deletion playground/external/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"slash3": "npm:slash@^3.0.0",
"slash5": "npm:slash@^5.1.0",
"vite": "workspace:*",
"vue": "^3.4.35",
"vue": "^3.4.38",
"vue32": "npm:vue@~3.2.0"
}
}
2 changes: 1 addition & 1 deletion playground/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"devDependencies": {
"@vitejs/test-json-module": "file:./json-module",
"express": "^4.19.2",
"vue": "^3.4.35"
"vue": "^3.4.38"
}
}
2 changes: 1 addition & 1 deletion playground/legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"vite": "workspace:*",
"@vitejs/plugin-legacy": "workspace:*",
"express": "^4.19.2",
"terser": "^5.31.3"
"terser": "^5.31.6"
}
}
Loading

0 comments on commit 34919df

Please sign in to comment.