Skip to content

Commit

Permalink
chore(deps): update dependency es-module-lexer to v1 (#9576)
Browse files Browse the repository at this point in the history
Co-authored-by: sapphi-red <green@sapphi.red>
  • Loading branch information
renovate[bot] and sapphi-red committed Aug 16, 2022
1 parent 3bffd14 commit 1d8613f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/vite/package.json
Expand Up @@ -90,7 +90,7 @@
"debug": "^4.3.4",
"dotenv": "^14.3.2",
"dotenv-expand": "^5.1.0",
"es-module-lexer": "^0.10.5",
"es-module-lexer": "^1.0.3",
"estree-walker": "^3.0.1",
"etag": "^1.8.1",
"fast-glob": "^3.2.11",
Expand Down
5 changes: 3 additions & 2 deletions packages/vite/src/node/optimizer/index.ts
Expand Up @@ -42,6 +42,7 @@ const jsMapExtensionRE = /\.js\.map$/i

export type ExportsData = {
hasImports: boolean
// exported names (for `export { a as b }`, `b` is exported name)
exports: readonly string[]
facade: boolean
// es-module-lexer has a facade detection but isn't always accurate for our
Expand Down Expand Up @@ -941,7 +942,7 @@ export async function extractExportsData(
const [imports, exports, facade] = parse(result.outputFiles[0].text)
return {
hasImports: imports.length > 0,
exports,
exports: exports.map((e) => e.n),
facade
}
}
Expand Down Expand Up @@ -973,7 +974,7 @@ export async function extractExportsData(
const [imports, exports, facade] = parseResult
const exportsData: ExportsData = {
hasImports: imports.length > 0,
exports,
exports: exports.map((e) => e.n),
facade,
hasReExports: imports.some(({ ss, se }) => {
const exp = entryContent.slice(ss, se)
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path'
import { performance } from 'node:perf_hooks'
import colors from 'picocolors'
import MagicString from 'magic-string'
import type { ImportSpecifier } from 'es-module-lexer'
import type { ExportSpecifier, ImportSpecifier } from 'es-module-lexer'
import { init, parse as parseImports } from 'es-module-lexer'
import { parse as parseJS } from 'acorn'
import type { Node } from 'estree'
Expand Down Expand Up @@ -189,7 +189,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
const start = performance.now()
await init
let imports: readonly ImportSpecifier[] = []
let exports: readonly string[] = []
let exports: readonly ExportSpecifier[] = []
source = stripBomTag(source)
try {
;[imports, exports] = parseImports(source)
Expand Down Expand Up @@ -676,7 +676,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
!isSelfAccepting &&
isPartiallySelfAccepting &&
acceptedExports.size >= exports.length &&
exports.every((name) => acceptedExports.has(name))
exports.every((e) => acceptedExports.has(e.n))
) {
isSelfAccepting = true
}
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1d8613f

Please sign in to comment.