Skip to content

Commit

Permalink
Merge branch 'main' into fix/optimize-deps-on-dev-ssr-opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Jun 29, 2022
2 parents a954e9e + ef749ed commit 8dc1995
Show file tree
Hide file tree
Showing 34 changed files with 545 additions and 344 deletions.
2 changes: 1 addition & 1 deletion docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ You can use `?init` which is similar to the previous behavior.
-import init from 'example.wasm'
+import init from 'example.wasm?init'
-init().then((instance) => {
-init().then((exports) => {
+init().then(({ exports }) => {
exports.test()
})
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
"ci-docs": "run-s build docs-build"
},
"devDependencies": {
"@babel/types": "^7.18.4",
"@microsoft/api-extractor": "^7.25.2",
"@babel/types": "^7.18.7",
"@microsoft/api-extractor": "^7.28.1",
"@rollup/plugin-typescript": "^8.3.3",
"@types/babel__core": "^7.1.19",
"@types/babel__standalone": "^7.1.4",
"@types/convert-source-map": "^1.5.2",
"@types/cross-spawn": "^6.0.2",
"@types/debug": "^4.1.7",
"@types/estree": "^0.0.51",
"@types/estree": "^0.0.52",
"@types/etag": "^1.8.1",
"@types/fs-extra": "^9.0.13",
"@types/hash-sum": "^1.0.0",
Expand All @@ -59,8 +59,8 @@
"@types/semver": "^7.3.10",
"@types/stylus": "^0.48.38",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"esbuild": "^0.14.47",
Expand All @@ -71,13 +71,13 @@
"execa": "^6.1.0",
"fs-extra": "^10.1.0",
"kill-port": "^1.6.1",
"lint-staged": "^13.0.2",
"lint-staged": "^13.0.3",
"minimist": "^1.2.6",
"node-fetch": "^3.2.6",
"npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
"playwright-chromium": "^1.22.2",
"pnpm": "^7.3.0",
"playwright-chromium": "^1.23.0",
"pnpm": "^7.4.0",
"prettier": "2.7.1",
"prompts": "^2.4.2",
"rimraf": "^3.0.2",
Expand All @@ -90,8 +90,8 @@
"typescript": "^4.6.4",
"unbuild": "^0.7.4",
"vite": "workspace:*",
"vitepress": "^1.0.0-alpha.2",
"vitest": "^0.15.1",
"vitepress": "^1.0.0-alpha.4",
"vitest": "^0.16.0",
"vue": "^3.2.37"
},
"simple-git-hooks": {
Expand All @@ -112,7 +112,7 @@
"eslint --cache --fix"
]
},
"packageManager": "pnpm@7.3.0",
"packageManager": "pnpm@7.4.0",
"pnpm": {
"overrides": {
"vite": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-lit-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
},
"devDependencies": {
"typescript": "^4.6.4",
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"lit": "^2.2.6"
},
"devDependencies": {
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
6 changes: 3 additions & 3 deletions packages/create-vite/template-preact-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.8.1"
"preact": "^10.8.2"
},
"devDependencies": {
"@preact/preset-vite": "^2.2.0",
"@preact/preset-vite": "^2.3.0",
"typescript": "^4.6.4",
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
6 changes: 3 additions & 3 deletions packages/create-vite/template-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.8.1"
"preact": "^10.8.2"
},
"devDependencies": {
"@preact/preset-vite": "^2.2.0",
"vite": "^2.9.12"
"@preact/preset-vite": "^2.3.0",
"vite": "^2.9.13"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"@types/react-dom": "^18.0.5",
"@vitejs/plugin-react": "^1.3.2",
"typescript": "^4.6.4",
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"@types/react": "^18.0.14",
"@types/react-dom": "^18.0.5",
"@vitejs/plugin-react": "^1.3.2",
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-svelte-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.49",
"@tsconfig/svelte": "^3.0.0",
"svelte": "^3.48.0",
"svelte-check": "^2.7.2",
"svelte-check": "^2.8.0",
"svelte-preprocess": "^4.10.7",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.49",
"svelte": "^3.48.0",
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vanilla-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"devDependencies": {
"typescript": "^4.6.4",
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"preview": "vite preview"
},
"devDependencies": {
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-vue-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.3",
"typescript": "^4.6.4",
"vite": "^2.9.12",
"vue-tsc": "^0.38.1"
"vite": "^2.9.13",
"vue-tsc": "^0.38.2"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.3",
"vite": "^2.9.12"
"vite": "^2.9.13"
}
}
4 changes: 2 additions & 2 deletions packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
"dependencies": {
"@babel/standalone": "^7.18.5",
"@babel/standalone": "^7.18.7",
"core-js": "^3.23.1",
"magic-string": "^0.26.2",
"regenerator-runtime": "^0.13.9",
Expand All @@ -46,7 +46,7 @@
"vite": "^3.0.0-alpha"
},
"devDependencies": {
"@babel/core": "^7.18.5",
"@babel/core": "^7.18.6",
"vite": "workspace:*"
}
}
10 changes: 5 additions & 5 deletions packages/plugin-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme",
"dependencies": {
"@babel/core": "^7.18.5",
"@babel/plugin-transform-react-jsx": "^7.17.12",
"@babel/plugin-transform-react-jsx-development": "^7.16.7",
"@babel/plugin-transform-react-jsx-self": "^7.17.12",
"@babel/plugin-transform-react-jsx-source": "^7.16.7",
"@babel/core": "^7.18.6",
"@babel/plugin-transform-react-jsx": "^7.18.6",
"@babel/plugin-transform-react-jsx-development": "^7.18.6",
"@babel/plugin-transform-react-jsx-self": "^7.18.6",
"@babel/plugin-transform-react-jsx-source": "^7.18.6",
"react-refresh": "^0.14.0"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx#readme",
"dependencies": {
"@babel/core": "^7.18.5",
"@babel/core": "^7.18.6",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-transform-typescript": "^7.18.4",
"@babel/plugin-transform-typescript": "^7.18.6",
"@vue/babel-plugin-jsx": "^1.1.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"vue": "^3.2.25"
},
"devDependencies": {
"@jridgewell/gen-mapping": "^0.3.1",
"@jridgewell/trace-mapping": "^0.3.13",
"@jridgewell/gen-mapping": "^0.3.2",
"@jridgewell/trace-mapping": "^0.3.14",
"debug": "^4.3.4",
"rollup": "^2.75.6",
"slash": "^4.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
},
"devDependencies": {
"@ampproject/remapping": "^2.2.0",
"@babel/parser": "^7.18.5",
"@babel/types": "^7.18.4",
"@jridgewell/trace-mapping": "^0.3.13",
"@babel/parser": "^7.18.6",
"@babel/types": "^7.18.7",
"@jridgewell/trace-mapping": "^0.3.14",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-commonjs": "^22.0.1",
"@rollup/plugin-dynamic-import-vars": "^1.4.3",
Expand Down
13 changes: 13 additions & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,19 @@ export async function resolveConfig(
)
}

if (
config.server?.force &&
!isBuild &&
config.optimizeDeps?.force === undefined
) {
resolved.optimizeDeps.force = true
logger.warn(
colors.yellow(
`server.force is deprecated, use optimizeDeps.force instead`
)
)
}

if (resolved.legacy?.buildRollupPluginCommonjs) {
const optimizerDisabled = resolved.optimizeDeps.disabled
if (!optimizerDisabled) {
Expand Down
12 changes: 3 additions & 9 deletions packages/vite/src/node/plugins/workerImportMetaUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin {

async transform(code, id, options) {
const ssr = options?.ssr === true
const query = parseRequest(id)
let s: MagicString | undefined
if (
!options?.ssr &&
(code.includes('new Worker') || code.includes('new SharedWorker')) &&
code.includes('new URL') &&
code.includes(`import.meta.url`)
) {
const query = parseRequest(id)
let s: MagicString | undefined
const cleanString = stripLiteral(code)
const workerImportMetaUrlRE =
/\bnew\s+(Worker|SharedWorker)\s*\(\s*(new\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/g
Expand All @@ -97,13 +98,6 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
const urlEnd = urlStart + emptyUrl.length
const rawUrl = code.slice(urlStart, urlEnd)

if (options?.ssr) {
this.error(
`\`new URL(url, import.meta.url)\` is not supported in SSR.`,
urlIndex
)
}

// potential dynamic template string
if (rawUrl[0] === '`' && /\$\{/.test(rawUrl)) {
this.error(
Expand Down
9 changes: 8 additions & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ export interface ServerOptions extends CommonServerOptions {
* @default true
*/
preTransformRequests?: boolean
/**
* Force dep pre-optimization regardless of whether deps have changed.
*
* @deprecated Use optimizeDeps.force instead, this option may be removed
* in a future minor version without following semver
*/
force?: boolean
}

export interface ResolvedServerOptions extends ServerOptions {
Expand Down Expand Up @@ -710,7 +717,7 @@ async function restartServer(server: ViteDevServer) {
let inlineConfig = server.config.inlineConfig
if (server._forceOptimizeOnRestart) {
inlineConfig = mergeConfig(inlineConfig, {
server: {
optimizeDeps: {
force: true
}
})
Expand Down
4 changes: 2 additions & 2 deletions playground/backend-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"preview": "vite preview"
},
"devDependencies": {
"sass": "^1.52.3",
"tailwindcss": "^3.1.3",
"sass": "^1.53.0",
"tailwindcss": "^3.1.4",
"fast-glob": "^3.2.11"
}
}
2 changes: 1 addition & 1 deletion playground/css-sourcemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"less": "^4.1.3",
"magic-string": "^0.26.2",
"sass": "^1.52.3",
"sass": "^1.53.0",
"stylus": "^0.58.1"
}
}
2 changes: 1 addition & 1 deletion playground/css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"fast-glob": "^3.2.11",
"less": "^4.1.3",
"postcss-nested": "^5.0.6",
"sass": "^1.52.3",
"sass": "^1.53.0",
"stylus": "^0.58.1"
}
}
2 changes: 1 addition & 1 deletion playground/multiple-entrypoints/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"devDependencies": {
"fast-glob": "^3.2.11",
"sass": "^1.52.3"
"sass": "^1.53.0"
}
}
4 changes: 2 additions & 2 deletions playground/react-classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"preview": "vite preview"
},
"dependencies": {
"react": "^18.1.0",
"react-dom": "^18.1.0"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@vitejs/plugin-react": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion playground/react-emotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"react-switch": "^7.0.0"
},
"devDependencies": {
"@babel/plugin-proposal-pipeline-operator": "^7.18.2",
"@babel/plugin-proposal-pipeline-operator": "^7.18.6",
"@emotion/babel-plugin": "^11.9.2",
"@vitejs/plugin-react": "workspace:*"
},
Expand Down
Loading

0 comments on commit 8dc1995

Please sign in to comment.