Skip to content

Support ESM Syntax in config files #509

@dummdidumm

Description

@dummdidumm

Is your feature request related to a problem? Please describe.
Config files need to be written in node-commonjs-style (no import ... or export const ... syntax) because we use require inside our extension to dynamically load dependencies. This is confusing to users and not obvious.

Describe the solution you'd like
Change the setup so that ESM syntax is supported.

  • Option 1: through some build/bundle step of the extension where a bundler might help by doing its magic (related: Please can you optimize the size of the VSCode extension #139 )
  • Option 2: switch to the await import(...); syntax, which is problematic because svelte-preprocess is looked up inside Document creation. That can't be made asynchronous because it's used inside the TS LS (same problem as for Bug: DocumentSnapshot.ts is not passing preprocessed markup to svelte2tsx  #339 ).
    • a) rework how we interact with the TS LS. Codesandbox Client might help for inspiration here (afaik they have to deal with asynchronousity, too)
    • b) move svelte-preprocess-call out of Document and into the start of the application. This would be a breaking change as you now can only have one top-level svelte.config.js and not multiple at different levels - but I doubt this will break anyone, and it would also align more with the semantics of other config files (only one per project).

Help and other ideas highly appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.feature requestNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions