Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Server fails on import when exported object constant has too many entries/is too large #951

Open
@aral

Description

@aral

I ran into an issue while creating and exporting a constant object that holds component versions of the ~1,500 icons in the Phorsphor icons library and I’ve created the simple reproduction below:

Description of issue

We have:

  • A generate.mjs Node.js file, which, when run, generates a generated.mjs file:

    import fs from 'node:fs'
    
    let source = `// @ts-check
    export const obj = {`
    for (let i = 0; i < 107634; i++) {
      source += `\n  key${i}: function () { return '' },`
    }
    source += '\n}'
    
    fs.writeFileSync('./generated.mjs', source)
  • A generated.mjs file that exports a constant object obj with N number of entries, each of which is a function that returns an empty string,

  • A consume.mjs file that imports { obj } from generated.mjs and references key10000:

    // @ts-check
    import { obj } from './generated.mjs'
    
    obj.key10000

Screen recording

https://vimeo.com/1073284447?share=copy#t=0

What happens

When 107,634 entries are created, resulting in a file that’s 4,194,285 bytes, everything works as it should.

When 107,635 entries are created, resulting in a file that’s 4,194,325 bytes, the language server shows the following error in consume.mjs:

Module '"./generated.mjs"' has no exported member 'obj'.

Interestingly (not shown in screen recording), I open generated.mjs in the same workspace as consume.msj, the error goes away. If I close the file, the error returns. So it only seems to affect imported objects where the source file is not open in the same workspace/session.

While the video recording shows the behaviour in Helix Editor, I also tested it our in VSCode and the behaviour is exactly the same.

What should happen

Both cases should work, or, if this is a hard limit of some sort that I’m hitting, it should be documented somewhere. (It’s possible that is and I haven’t been able to find it. I have looked quite a bit.)

Versions

Running on latest macOS with TypeScript language server installed via brew for Helix Editor.

  • tsc --version: Version 5.8.3
  • VSCode version info:
Version: 1.99.0 (Universal)
Commit: 4437686ffebaf200fa4a6e6e67f735f3edf24ada
Date: 2025-04-02T21:35:19.530Z (4 days ago)
Electron: 34.3.2
ElectronBuildId: 11161073
Chromium: 132.0.6834.210
Node.js: 20.18.3
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions