Skip to content

Commit

Permalink
upgrade and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Menci committed Dec 19, 2024
1 parent 259d071 commit 740c00f
Show file tree
Hide file tree
Showing 10 changed files with 4,503 additions and 4,899 deletions.
18 changes: 11 additions & 7 deletions e2e/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import { jest } from "@jest/globals";
import { firefox } from "playwright";

// import type { RollupOutput } from "rollup";
type RollupOutput = any;
import type { RollupOutput } from "rollup";
import vitePluginWasm from "../src/index.js";

import express from "express";
Expand Down Expand Up @@ -45,6 +44,7 @@ type VitePackages =
};

async function buildAndStartProdServer(
viteVersion: number,
vitePackages: VitePackages,
transformTopLevelAwait: boolean,
modernOnly: boolean
Expand All @@ -56,6 +56,7 @@ async function buildAndStartProdServer(
build: {
target: "esnext"
},
cacheDir: path.resolve(__dirname, "node_modules", `.vite${viteVersion}`),
plugins: [
...(modernOnly ? [] : [vitePluginLegacy()]),
vitePluginWasm(),
Expand Down Expand Up @@ -104,12 +105,13 @@ async function buildAndStartProdServer(
return `http://127.0.0.1:${port}/`;
}

async function startDevServer(vitePackages: VitePackages): Promise<string> {
async function startDevServer(viteVersion: number, vitePackages: VitePackages): Promise<string> {
const { vite } = vitePackages;

const devServer = await vite.createServer({
root: __dirname,
plugins: [vitePluginWasm()],
cacheDir: path.resolve(__dirname, "node_modules", `.vite${viteVersion}`),
logLevel: "error"
});

Expand All @@ -132,12 +134,14 @@ async function createBrowser(modernBrowser: boolean) {
}

async function runTest(
viteVersion: number,
vitePackages: VitePackages,
devServer: boolean,
transformTopLevelAwait: boolean,
modernBrowser: boolean
) {
const server = await (devServer ? startDevServer : buildAndStartProdServer)(
viteVersion,
vitePackages,
transformTopLevelAwait,
modernBrowser
Expand Down Expand Up @@ -204,19 +208,19 @@ export function runTests(viteVersion: number, importVitePackages: () => Promise<
}

it(`vite ${viteVersion}: should work on modern browser in Vite dev server`, async () => {
await runTestWithRetry(await importVitePackages(), true, false, true);
await runTestWithRetry(viteVersion, await importVitePackages(), true, false, true);
});

it(`vite ${viteVersion}: should work on modern browser without top-level await transform`, async () => {
await runTestWithRetry(await importVitePackages(), false, false, true);
await runTestWithRetry(viteVersion, await importVitePackages(), false, false, true);
});

it(`vite ${viteVersion}: should work on modern browser with top-level await transform`, async () => {
await runTestWithRetry(await importVitePackages(), false, true, true);
await runTestWithRetry(viteVersion, await importVitePackages(), false, true, true);
});

it(`vite ${viteVersion}: should work on legacy browser`, async () => {
await runTestWithRetry(await importVitePackages(), false, true, false);
await runTestWithRetry(viteVersion, await importVitePackages(), false, true, false);
});
});
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git a/node_modules/vite/dist/node/chunks/dep-689425f3.js b/node_modules/vite/dist/node/chunks/dep-689425f3.js
index babf8d5..019289d 100644
--- a/node_modules/vite/dist/node/chunks/dep-689425f3.js
+++ b/node_modules/vite/dist/node/chunks/dep-689425f3.js
diff --git a/node_modules/vite/dist/node/chunks/dep-0a035c79.js b/node_modules/vite/dist/node/chunks/dep-0a035c79.js
index 57ca5f3..d39bfca 100644
--- a/node_modules/vite/dist/node/chunks/dep-0a035c79.js
+++ b/node_modules/vite/dist/node/chunks/dep-0a035c79.js
@@ -38271,7 +38271,7 @@ const isModernFlag = `__VITE_IS_MODERN__`;
const preloadMethod = `__vitePreload`;
const preloadMarker = `__VITE_PRELOAD__`;
Expand Down
611 changes: 303 additions & 308 deletions e2e/vite2/yarn.lock

Large diffs are not rendered by default.

654 changes: 316 additions & 338 deletions e2e/vite3/yarn.lock

Large diffs are not rendered by default.

2,445 changes: 1,128 additions & 1,317 deletions e2e/vite4/yarn.lock

Large diffs are not rendered by default.

2,536 changes: 1,173 additions & 1,363 deletions e2e/vite5/yarn.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: "ts-jest/presets/default-esm",
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
export default {
verbose: true,
transform: {
"^.+\\.ts?$": [
"ts-jest",
{
useESM: true
useESM: true,
tsconfig: "tsconfig.jest.json"
}
]
},
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "vite-plugin-wasm",
"version": "3.3.0",
"description": "Add WebAssembly ESM integration (aka. Webpack's `asyncWebAssembly`) to Vite and support `wasm-pack` generated modules.",
"type": "module",
"types": "./exports/require.d.cts",
"main": "./exports/require.cjs",
"module": "./exports/import.mjs",
Expand Down Expand Up @@ -35,25 +36,25 @@
},
"packageManager": "yarn@1.22.21",
"devDependencies": {
"@babel/core": "^7.23.5",
"@babel/preset-env": "^7.23.5",
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@jest/types": "^29.6.3",
"@jsona/openapi": "^0.2.5",
"@syntect/wasm": "^0.0.4",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.11",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.14",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"express": "^4.18.2",
"express": "^4.21.2",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
"mime": "^4.0.0",
"mime": "^4.0.6",
"playwright": "1.23.3",
"playwright-core": "1.23.3",
"prettier": "^3.1.0",
"terser": "^5.26.0",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3",
"prettier": "^3.4.2",
"terser": "^5.37.0",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2",
"vite": "6",
"wait-port": "^1.1.0"
},
Expand Down
6 changes: 6 additions & 0 deletions tsconfig.jest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ESNext"
}
}
Loading

0 comments on commit 740c00f

Please sign in to comment.