redhat-developer / redhat-developer/yaml-language-server

"Class extends value undefined is not a constructor or null" when 1.11.0 or later version used as an umd library

Open
#879 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
352
Avg merge
2d 7h
Merged PRs (30d)
11

Description

Describe the bug

I'm trying to use this project as an umd library. It works fine with 1.7.0 version.
With v1.12.0, everyting compiles fine. But at runtime, I get the following error:

/home/wyf/umd-test/node_modules/yaml-language-server/lib/umd/languageservice/parser/yaml-documents.js:29
    class SingleYAMLDocument extends jsonParser07_1.JSONDocument {
                                                    ^

TypeError: Class extends value undefined is not a constructor or null
    at /home/wyf/umd-test/node_modules/yaml-language-server/lib/umd/languageservice/parser/yaml-documents.js:29:53
    at /home/wyf/umd-test/node_modules/yaml-language-server/lib/umd/languageservice/parser/yaml-documents.js:7:17
    at Object.<anonymous> (/home/wyf/umd-test/node_modules/yaml-language-server/lib/umd/languageservice/parser/yaml-documents.js:13:3)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at /home/wyf/umd-test/node_modules/yaml-language-server/lib/umd/languageservice/services/documentSymbols.js:19:30

Expected Behavior

When v1.12.0 is used as a library, it should work as with v.1.7.0

Current Behavior

Throws TypeError at runtime

Steps to Reproduce

One can clone https://github.com/1yefuwang1/yaml-language-server-lib-sample for code and steps to reproduce.

Environment

  • Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the UMD reproduction in the linked yaml-language-server-lib-sample and inspect the generated lib/umd/languageservice/parser/yaml-documents.js, where JSONDocument is undefined. Run the sample with version 1.12.0 and compare its behavior with 1.7.0. Done means the package loads and runs as a UMD library without the runtime TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.