bublejs / bublejs/buble

es5 in es2015 conflict with classname.apply

Open
#130 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
874
Forks
62
PR merge metrics
No merged PRs in 30d

Description

I'm getting this error `Class constructor SC cannot be invoked without 'new'`.

There's a function imported from a module that takes a class, and invokes new on the passed class. This other module has been transpiled to es5, but the local project is in es2015. So classes are strictly classes locally, but when a class is passed to that function the error comes up because an actual class is being passed into that es5 transpiled function.

The main confounding detail is the `super` call which gets transformed to `ClassName.apply()` which will be the line that throws the error. That is where `ClassName` is a es2015 class that was passed into the es5 function.

I'm not sure there is even a way to fix this problem. https://esdiscuss.org/topic/accesssing-es6-class-constructor-function

The problems listed on that esdiscuss thread are similar to what I'm having. Things using DI are breaking because of incompatible versions of js.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no repository files or tests; start by reproducing the ES5/ES2015 class interaction described, focusing on the transformed super call and its ClassName.apply failure. Done would mean establishing compatible behavior for mixed-transpilation DI use cases or clearly documenting the limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.