Skip to content

Comments

refactor: remove acorn#16238

Merged
bluwy merged 6 commits intovitejs:mainfrom
sapphi-red:refactor/remove-acorn
May 29, 2024
Merged

refactor: remove acorn#16238
bluwy merged 6 commits intovitejs:mainfrom
sapphi-red:refactor/remove-acorn

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Mar 22, 2024

Description

Rollup v4 doesn't use acorn and exposes parseAst. This PR removes acorn by using that function instead.

  • package size: 828.6 kB -> 772.2 kB
  • unpacked size: 3.6 MB -> 3.3MB

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added the p1-chore Doesn't change code behavior (priority) label Mar 22, 2024
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

import { findStaticImports, parseStaticImport } from 'mlly'
import { parseAst } from 'rollup/parseAst'
import type { StaticImport } from 'mlly'
import { ESM_STATIC_IMPORT_RE, parseStaticImport } from 'mlly'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +235 to +239
const end =
findCorrespondingCloseParenthesisPosition(
cleanCode,
start + match[0].length,
) + 1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous implementation relied on acorn to find the end position of import.meta.glob(. In this new implementation, it finds the close parenthesis of import.meta.glob( instead.

@sapphi-red
Copy link
Member Author

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

@vite-ecosystem-ci
Copy link

@patak-dev patak-dev added this to the 5.3 milestone Mar 26, 2024
@patak-dev patak-dev added p2-nice-to-have Not breaking anything but nice to have (priority) and removed p1-chore Doesn't change code behavior (priority) labels Mar 26, 2024
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor!

bluwy
bluwy previously approved these changes May 14, 2024
@bluwy
Copy link
Member

bluwy commented May 29, 2024

The flaky CI fails is happening in main too. I'm investigating this and will submit a fix later. Merging this for now.

@bluwy bluwy merged commit 454e2d1 into vitejs:main May 29, 2024
@sapphi-red sapphi-red deleted the refactor/remove-acorn branch May 30, 2024 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants