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

[BUG] Uncaught TypeError: Cannot read property 'Parser' of undefined in Antlr4ts #3317

Open
computeone opened this issue May 17, 2021 · 3 comments

Comments

@computeone
Copy link

computeone commented May 17, 2021

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use package manager yarn
  • I run Snowpack on Windows.
  • I run Snowpack on Node.js v12+

Describe the bug

antlr4ts Uncaught TypeError: Cannot read property 'Parser' of undefined
A quick, clear, concise summary of what the bug is.
Uncaught TypeError: Cannot read property 'Parser' of undefined at :3000/_snowpack/pkg/antlr4ts.v0.5.0-alpha.4/common/BailErrorStrategy-691ae00f.js:6667 at createCommonjsModule (:3000/_snowpack/pkg/antlr4ts.v0.5.0-alpha.4/common/_commonjsHelpers-8c19dec8.js:14) at :3000/_snowpack/pkg/antlr4ts.v0.5.0-alpha.4/common/BailErrorStrategy-691ae00f.js:6624

To Reproduce

Addlet input = CharStreams.fromString("100+200"); in any line in src/App.tsx or in any file.
yarn start --polyfill-node

  1. npx create-snowpack-app react-snowpack --template @snowpack/app-template-react-typescript
  2. Addlet input = CharStreams.fromString("100+200"); in any line in src/App.tsx or in any file.
  3. yarn start --polyfill-node
  4. See error!

Expected behavior

snowpack can run antlr4ts code

@computeone computeone changed the title [BUG] [BUG] Uncaught TypeError: Cannot read property 'Parser' of undefined in Antlr4ts May 17, 2021
@markduan
Copy link

I have a similar issue here

intl-messageformat.v2.2.0.js:429 Uncaught TypeError: Cannot read property 'parse' of undefined
    at intl-messageformat.v2.2.0.js:429
    at createCommonjsModule (intl-messageformat.v2.2.0.js:10)
    at intl-messageformat.v2.2.0.js:295

@lstrive-yn
Copy link

I have a similar issue here

intl-messageformat.v2.2.0.js:429 Uncaught TypeError: Cannot read property 'parse' of undefined
    at intl-messageformat.v2.2.0.js:429
    at createCommonjsModule (intl-messageformat.v2.2.0.js:10)
    at intl-messageformat.v2.2.0.js:295

I got a same issue but can't resolve it yet, any advices?

@AJamesPhillips
Copy link

AJamesPhillips commented Oct 10, 2022

I have got antlr4ts to "work" in my snowpack'd browser code.

In my node_modules/.cache/snowpack/build/antlr4ts@0.5.0-alpha.4/common/BailErrorStrategy-0b50f9ab.js I noticed the var Parser_1 = createCommonjsModule(function (module, exports) { ... }); code was after its use/reference by let ParserInterpreter = class ParserInterpreter extends Parser_1.Parser { ... });

Moving that var Parser_1 ... code above let ParserInterpreter ... fixed my error that was similar to the Cannot read property 'Parser' of undefined at :3000/_snowpack/pkg/antlr4ts.v0.5.0-alpha.4/common/BailErrorStrategy-691ae00f.js:6667 mentioned by the OP.
(Mine said TypeError: Parser_1 is undefined with stacktrack starting: http://localhost:8080/snowpack/pkg/antlr4ts.v0.5.0-alpha.4/common/BailErrorStrategy-0b50f9ab.js [:7784:25]).

I then ran into a second error of:

**Unhandled Runtime Error**
TypeError: ({default:function assert(value, message) {
  if (!value) fail(value, true, message, '==', ok);
}, AssertionError:function AssertionError(options) {
  this.name = 'AssertionError';
  // ... omitted lines for brevity ...
}}) is not a function
http://localhost:8080/snowpack/pkg/antlr4ts.v0.5.0-alpha.4/common/BailErrorStrategy-0b50f9ab.js [:7277:19] 

I fixed this second error by replacing line 3290 in node_modules/.cache/snowpack/build/antlr4ts@0.5.0-alpha.4/common/SemanticContext-af41e21e.js which had var assert$1 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(_polyfillNode_assert); with var assert$1 = assert

The code now works in my browser application with SnowPack... obviously this is not a proper fix so we'd need to go to SnowPack or to antlr4ts to get a proper fix. I'm not yet clear on where's best to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants