Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 19, 2022
2 parents 07a01b5 + 9a7b133 commit cd57010
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
5 changes: 4 additions & 1 deletion docs/config/index.md
Expand Up @@ -27,14 +27,17 @@ You can also explicitly specify a config file to use with the `--config` CLI opt
vite --config my-config.js
```

Note that Vite will replace `__filename`, `__dirname`, and `import.meta.url`. Using these as variable names will result in an error:
::: tip NOTE
Vite will replace `__filename`, `__dirname`, and `import.meta.url` in **CommonJS** and **TypeScript** config files. Using these as variable names will result in an error:

```js
const __filename = "value"
// will be transformed to
const "path/vite.config.js" = "value"
```

:::

### Config Intellisense

Since Vite ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints:
Expand Down
12 changes: 12 additions & 0 deletions packages/vite/CHANGELOG.md
@@ -1,3 +1,15 @@
## 2.9.0-beta.4 (2022-03-19)

* fix: add version to optimized chunks, fix #7323 (#7350) ([1be1db6](https://github.com/vitejs/vite/commit/1be1db6)), closes [#7323](https://github.com/vitejs/vite/issues/7323) [#7350](https://github.com/vitejs/vite/issues/7350)
* fix: browser cache of newly discovered deps (#7378) ([392a0de](https://github.com/vitejs/vite/commit/392a0de)), closes [#7378](https://github.com/vitejs/vite/issues/7378)
* fix: do not warn (about not being able to bundle non module scripts) when src is an external url (#7 ([0646fe8](https://github.com/vitejs/vite/commit/0646fe8)), closes [#7380](https://github.com/vitejs/vite/issues/7380)
* fix: overwrite deps info browserHash only on commit (#7359) ([1e9615d](https://github.com/vitejs/vite/commit/1e9615d)), closes [#7359](https://github.com/vitejs/vite/issues/7359)
* chore: fix typo in comment (#7370) ([e682863](https://github.com/vitejs/vite/commit/e682863)), closes [#7370](https://github.com/vitejs/vite/issues/7370)
* chore: update es-module-lexer (#7357) ([fde0f3c](https://github.com/vitejs/vite/commit/fde0f3c)), closes [#7357](https://github.com/vitejs/vite/issues/7357)
* chore(deps): update all non-major dependencies (#6905) ([839665c](https://github.com/vitejs/vite/commit/839665c)), closes [#6905](https://github.com/vitejs/vite/issues/6905)



## 2.9.0-beta.3 (2022-03-16)

* fix: delayed full page reload (#7347) ([fa0820a](https://github.com/vitejs/vite/commit/fa0820a)), closes [#7347](https://github.com/vitejs/vite/issues/7347)
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
@@ -1,6 +1,6 @@
{
"name": "vite",
"version": "2.9.0-beta.3",
"version": "2.9.0-beta.4",
"license": "MIT",
"author": "Evan You",
"description": "Native-ESM powered web dev build tool",
Expand Down
9 changes: 3 additions & 6 deletions packages/vite/src/node/optimizer/index.ts
Expand Up @@ -633,10 +633,7 @@ export function getHash(text: string) {
return createHash('sha256').update(text).digest('hex').substring(0, 8)
}

export function getOptimizedBrowserHash(
hash: string,
deps: Record<string, string>
) {
function getOptimizedBrowserHash(hash: string, deps: Record<string, string>) {
return getHash(hash + JSON.stringify(deps))
}

Expand Down Expand Up @@ -858,8 +855,8 @@ export function optimizeDepInfoFromFile(
): OptimizedDepInfo | undefined {
return (
findFileInfo(metadata.optimized, file) ||
findFileInfo(metadata.chunks, file) ||
findFileInfo(metadata.discovered, file)
findFileInfo(metadata.discovered, file) ||
findFileInfo(metadata.chunks, file)
)
}

Expand Down
8 changes: 6 additions & 2 deletions packages/vite/src/node/optimizer/registerMissing.ts
Expand Up @@ -271,7 +271,7 @@ export function createOptimizedDeps(
runOptimizer(ssr)
}

const optimizedDepsTimestamp = Date.now()
const discoveredTimestamp = Date.now()

function getDiscoveredBrowserHash(
hash: string,
Expand All @@ -282,7 +282,7 @@ export function createOptimizedDeps(
hash +
JSON.stringify(deps) +
JSON.stringify(missing) +
optimizedDepsTimestamp
discoveredTimestamp
)
}

Expand All @@ -301,6 +301,10 @@ export function createOptimizedDeps(
if (optimized) {
return optimized
}
const chunk = metadata.chunks[id]
if (chunk) {
return chunk
}
let missing = metadata.discovered[id]
if (missing) {
// We are already discover this dependency
Expand Down
8 changes: 5 additions & 3 deletions packages/vite/src/node/plugins/html.ts
Expand Up @@ -297,9 +297,11 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
someScriptsAreAsync ||= isAsync
someScriptsAreDefer ||= !isAsync
} else if (url && !isPublicFile) {
config.logger.warn(
`<script src="${url}"> in "${publicPath}" can't be bundled without type="module" attribute`
)
if (!isExcludedUrl(url)) {
config.logger.warn(
`<script src="${url}"> in "${publicPath}" can't be bundled without type="module" attribute`
)
}
} else if (node.children.length) {
const scriptNode = node.children.pop()! as TextNode
const code = scriptNode.content
Expand Down

0 comments on commit cd57010

Please sign in to comment.