René's URL Explorer Experiment


Title: fix(vite): scan top-level imports with Vite's native parser by aleclarson · Pull Request #11634 · NativeScript/NativeScript · GitHub

Open Graph Title: fix(vite): scan top-level imports with Vite's native parser by aleclarson · Pull Request #11634 · NativeScript/NativeScript

X Title: fix(vite): scan top-level imports with Vite's native parser by aleclarson · Pull Request #11634 · NativeScript/NativeScript

Description: What The /ns/m dev route parses each served module with Babel several times just to find its top-level imports (collectTopLevelImportRecords in two places, plus the dev default-import link check). On modules whose code sits on a few very long lines, Babel's skipBlockComment becomes quadratic: for every block comment it runs lineBreakG.test(this.input) from the comment start to the next line break anywhere in the input, not just to the comment's end. Real case: a 3.9 MB dependency chunk (shaders/dist/core/std-*.js) is transformed by Vite's dev pipeline into 225 lines, the longest 1.9 MB with about 2,000 block comments. One Babel parse of that output takes ~1.5 s (0.26 s on the original multi-line file), and a single cold request did about six of them. CPU profiles showed @babel/parser at 8.7 s of an 11.25 s request, 7.2 s of it in skipBlockComment. Because this runs synchronously, the dev server's event loop is blocked for the whole request, and the iOS runtime's module loader timed out during cold boot (NSURLErrorDomain -1001) before the app could start. How New parseTopLevelStatements(code) in websocket-served-module-helpers.ts returns top-level statements from Vite's parseAst(code, { lang: 'tsx' }) (Oxc), or null if Oxc rejects the code. Both collectTopLevelImportRecords implementations use it first and fall back to the unchanged Babel parse. If both fail, they still return []. Node checks are plain type comparisons that work on either AST. Output fields are unchanged. New collectStaticImportDefaultIntents(code) replaces the link check's inline parse and traverse. Static imports can only appear at top level, so scanning top-level ImportDeclarations is equivalent. It falls back to the previous Babel parse and traverse, and still throws on a double failure, so the caller's try/catch behaves as before. Other Babel uses (astExtractImportsAndStripTypes, collectReExportAndDynamicImportSources, the normalizer) are untouched. vite is already a dependency of @nativescript/vite (^8.0.0), so no new dependency. Test plan npx vitest run hmr/server/websocket-served-module-helpers.spec.ts hmr/server/websocket-import-records-fallback.spec.ts: 26 pass. Covers default, named and string-named specifiers, exact text slices after non-ASCII text, import type, TS+JSX input, no imports, a forced Oxc failure falling back to Babel, ensureNativeScriptModuleBindings on both paths, and default-import intents. Long-line regression: one import plus a single line with 12,000 block comments. Babel-only took 10.3 s on this machine; the new path takes about 0.05 s. The spec asserts under 2 s. npx nx run vite:build. Touched files are lint-clean; vite:lint still reports 3 existing errors in untouched files (configuration/base.ts, css-device-module.ts). Applied as a patch to published 8.0.20 and 8.0.21 in a large app. A cold request for the module above went from 11–21 s to 5–9 s on a heavily loaded host (load average 40–190); the rest is untouched Babel work and the Vite transform. The @babel/parser share dropped from 8.7 s to 1.2 s. A serial cold crawl of the app's 1,443-module boot graph went from 241.6 s to 108.9 s, with the slowest module dropping from 4.9 s to 1.4 s. The same app now completes an iOS simulator HMR cycle from a cold dev server: launch, an in-place JS edit on the same process, and a native edit with rebuild and relaunch. Before this change it failed during module loading.

Open Graph Description: What The /ns/m dev route parses each served module with Babel several times just to find its top-level imports (collectTopLevelImportRecords in two places, plus the dev default-import link check). ...

X Description: What The /ns/m dev route parses each served module with Babel several times just to find its top-level imports (collectTopLevelImportRecords in two places, plus the dev default-import link check). ...

Opengraph URL: https://github.com/NativeScript/NativeScript/pull/11634

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:cfb9bb58-4b08-99ae-4c6c-123783e8d655
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE0A8:305B07:161B0B5:1D2A924:6B01303A
html-safe-nonce18ca11feddc01749d3cdc7fa1ff5512498783abadb0762f17fff9d44732db648
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEE4OjMwNUIwNzoxNjFCMEI1OjFEMkE5MjQ6NkIwMTMwM0EiLCJ2aXNpdG9yX2lkIjoiMzk0NjA5MjA2MDczMzQxOTU3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac05ca31f5cd256420366777bdc9516d9712aacf92073ab357c97f70d086f137cf
hovercard-subject-tagpull_request:5248316771
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/NativeScript/NativeScript/pull/11634/files
twitter:imagehttps://avatars.githubusercontent.com/u/1925840?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1925840?s=400&v=4
og:image:altWhat The /ns/m dev route parses each served module with Babel several times just to find its top-level imports (collectTopLevelImportRecords in two places, plus the dev default-import link check). ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id31492490
octolytics-dimension-repository_nwoNativeScript/NativeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id31492490
octolytics-dimension-repository_network_root_nwoNativeScript/NativeScript
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/NativeScript/NativeScript/pull/11634/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2FNativeScript%2Fpull%2F11634%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2FNativeScript%2Fpull%2F11634%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=NativeScript%2FNativeScript
Reloadhttps://github.com/NativeScript/NativeScript/pull/11634/files
Reloadhttps://github.com/NativeScript/NativeScript/pull/11634/files
Reloadhttps://github.com/NativeScript/NativeScript/pull/11634/files
NativeScripthttps://github.com/NativeScript
NativeScripthttps://github.com/NativeScript/NativeScript
Codehttps://github.com/NativeScript/NativeScript
Issues231 (231)https://github.com/NativeScript/NativeScript/issues
Pull requests107 (107)https://github.com/NativeScript/NativeScript/pulls
Discussionshttps://github.com/NativeScript/NativeScript/discussions
Actionshttps://github.com/NativeScript/NativeScript/actions
Projectshttps://github.com/NativeScript/NativeScript/projects
Wikihttps://github.com/NativeScript/NativeScript/wiki
Security and qualityhttps://github.com/NativeScript/NativeScript/security
Insightshttps://github.com/NativeScript/NativeScript/insights
Sign up for GitHub https://github.com/signup?return_to=%2FNativeScript%2FNativeScript%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FNativeScript%2FNativeScript%2Fissues%2Fnew%2Fchoose
aleclarsonhttps://github.com/aleclarson
NativeScript:mainhttps://github.com/NativeScript/NativeScript/tree/main
aleclarson:fix/vite-oxc-import-recordshttps://github.com/aleclarson/nativescript/tree/fix/vite-oxc-import-records
Conversation 2 https://github.com/NativeScript/NativeScript/pull/11634
Commits 1 https://github.com/NativeScript/NativeScript/pull/11634/commits
Checks 6 https://github.com/NativeScript/NativeScript/pull/11634/checks
Files changed 5 https://github.com/NativeScript/NativeScript/pull/11634/files
fix(vite): scan top-level imports with Vite's native parser https://github.com/NativeScript/NativeScript/pull/11634/files#top
Show all changes 1 commit https://github.com/NativeScript/NativeScript/pull/11634/files
f9a2a09 fix(vite): scan top-level imports with Vite's native parser aleclarson Nov 10, 2026 https://github.com/NativeScript/NativeScript/pull/11634/commits/f9a2a09a9e1aecaa700522b4b62e0ddd0df62907
Clear filters https://github.com/NativeScript/NativeScript/pull/11634/files
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11634/files
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11634/files
websocket-import-records-fallback.spec.ts https://github.com/NativeScript/NativeScript/pull/11634/files#diff-b94163933598df900687461fc74ee93c4b1845e0a9bbf81153f190d773699404
websocket-module-bindings.ts https://github.com/NativeScript/NativeScript/pull/11634/files#diff-37de759e149a80259c3729fdcc8366d7c8258bf22bf6fb2ad6b04e79cedae011
websocket-ns-m.ts https://github.com/NativeScript/NativeScript/pull/11634/files#diff-94dcd512e1f0c10c1f6eee77f68a8730865a2eab471fe9641398d8baae5895a7
websocket-served-module-helpers.spec.ts https://github.com/NativeScript/NativeScript/pull/11634/files#diff-6171fb454e6259e30fd20b755363a3c6d3bd3d48f0b330305f77ee0bcfa3fed2
websocket-served-module-helpers.ts https://github.com/NativeScript/NativeScript/pull/11634/files#diff-65ff1595113e340d0ef1bff59ef9703a6409f9dd3cd7b430c250e9faed8dcf4d
packages/vite/hmr/server/websocket-import-records-fallback.spec.tshttps://github.com/NativeScript/NativeScript/pull/11634/files#diff-b94163933598df900687461fc74ee93c4b1845e0a9bbf81153f190d773699404
View file https://github.com/NativeScript/NativeScript/blob/f9a2a09a9e1aecaa700522b4b62e0ddd0df62907/packages/vite/hmr/server/websocket-import-records-fallback.spec.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11634/{{ revealButtonHref }}
packages/vite/hmr/server/websocket-module-bindings.tshttps://github.com/NativeScript/NativeScript/pull/11634/files#diff-37de759e149a80259c3729fdcc8366d7c8258bf22bf6fb2ad6b04e79cedae011
View file https://github.com/NativeScript/NativeScript/blob/f9a2a09a9e1aecaa700522b4b62e0ddd0df62907/packages/vite/hmr/server/websocket-module-bindings.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11634/{{ revealButtonHref }}
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-37de759e149a80259c3729fdcc8366d7c8258bf22bf6fb2ad6b04e79cedae011
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-37de759e149a80259c3729fdcc8366d7c8258bf22bf6fb2ad6b04e79cedae011
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-37de759e149a80259c3729fdcc8366d7c8258bf22bf6fb2ad6b04e79cedae011
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-37de759e149a80259c3729fdcc8366d7c8258bf22bf6fb2ad6b04e79cedae011
packages/vite/hmr/server/websocket-ns-m.tshttps://github.com/NativeScript/NativeScript/pull/11634/files#diff-94dcd512e1f0c10c1f6eee77f68a8730865a2eab471fe9641398d8baae5895a7
View file https://github.com/NativeScript/NativeScript/blob/f9a2a09a9e1aecaa700522b4b62e0ddd0df62907/packages/vite/hmr/server/websocket-ns-m.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11634/{{ revealButtonHref }}
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-94dcd512e1f0c10c1f6eee77f68a8730865a2eab471fe9641398d8baae5895a7
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-94dcd512e1f0c10c1f6eee77f68a8730865a2eab471fe9641398d8baae5895a7
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-94dcd512e1f0c10c1f6eee77f68a8730865a2eab471fe9641398d8baae5895a7
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-94dcd512e1f0c10c1f6eee77f68a8730865a2eab471fe9641398d8baae5895a7
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-94dcd512e1f0c10c1f6eee77f68a8730865a2eab471fe9641398d8baae5895a7
packages/vite/hmr/server/websocket-served-module-helpers.spec.tshttps://github.com/NativeScript/NativeScript/pull/11634/files#diff-6171fb454e6259e30fd20b755363a3c6d3bd3d48f0b330305f77ee0bcfa3fed2
View file https://github.com/NativeScript/NativeScript/blob/f9a2a09a9e1aecaa700522b4b62e0ddd0df62907/packages/vite/hmr/server/websocket-served-module-helpers.spec.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11634/{{ revealButtonHref }}
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-6171fb454e6259e30fd20b755363a3c6d3bd3d48f0b330305f77ee0bcfa3fed2
packages/vite/hmr/server/websocket-served-module-helpers.tshttps://github.com/NativeScript/NativeScript/pull/11634/files#diff-65ff1595113e340d0ef1bff59ef9703a6409f9dd3cd7b430c250e9faed8dcf4d
View file https://github.com/NativeScript/NativeScript/blob/f9a2a09a9e1aecaa700522b4b62e0ddd0df62907/packages/vite/hmr/server/websocket-served-module-helpers.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11634/{{ revealButtonHref }}
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-65ff1595113e340d0ef1bff59ef9703a6409f9dd3cd7b430c250e9faed8dcf4d
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-65ff1595113e340d0ef1bff59ef9703a6409f9dd3cd7b430c250e9faed8dcf4d
https://github.com/NativeScript/NativeScript/pull/11634/files#diff-65ff1595113e340d0ef1bff59ef9703a6409f9dd3cd7b430c250e9faed8dcf4d
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11634/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.