Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(template-compiler): update acorn and fix its types #4132

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/@lwc/template-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@
}
},
"dependencies": {
"//": "Acorn is pinned due to a breaking change in its types in 8.11: https://github.com/acornjs/acorn/issues/1260",
"@lwc/errors": "6.5.0",
"@lwc/shared": "6.5.0",
"acorn": "8.10.0",
"acorn": "~8.11.3",
"astring": "~1.8.6",
"estree-walker": "~2.0.2",
"he": "~1.2.0"
Expand Down
16 changes: 16 additions & 0 deletions packages/@lwc/template-compiler/src/typings/acorn.d.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

These type overrides are potentially subtle/hidden. How can we make them more visible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have a convention of using src/typings in all our packages for any type overrides. There are a few packages where we do this.

I dunno what to do about that, other than "it's just one of those things you have to know" 🤷

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import type { Expression, Options } from 'acorn';

// Acorn shipped a breaking change in its types: https://github.com/acornjs/acorn/issues/1260
// This is a workaround based on Svelte's solution: https://github.com/sveltejs/svelte/pull/10301
declare module 'acorn' {
export function isIdentifierStart(code: number, astral?: boolean): boolean;
export function isIdentifierChar(code: number, astral?: boolean): boolean;
export function parseExpressionAt(input: string, pos: number, options: Options): Expression;
}
7 changes: 1 addition & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2599,12 +2599,7 @@ acorn-walk@^8.0.2:
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.2.tgz#7703af9415f1b6db9315d6895503862e231d34aa"
integrity sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==

[email protected]:
version "8.10.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5"
integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==

acorn@^8.1.0, acorn@^8.8.1, acorn@^8.8.2, acorn@^8.9.0:
acorn@^8.1.0, acorn@^8.8.1, acorn@^8.8.2, acorn@^8.9.0, acorn@~8.11.3:
version "8.11.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a"
integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==
Expand Down
Loading