question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic import() broken on Excalibur 0.25.1 and newer.

See original GitHub issue

Steps to Reproduce

The attempt to use a dynamic import() as seen in @kamranayub’s CodeSandbox Example does not work after upgrading to/beyond 0.25.1, as it results in this error: TypeError: undefined is not a non-null object (Firefox) and TypeError: Object.defineProperty called on non-object (Chrome)

Here is a prepared CodeSandbox which showcases the issue: https://codesandbox.io/s/cool-ritchie-uu1m7v

Expected Result

Dynamic imports should work with the ESM bundle.

Actual Result

Attempting to use a dynamic import with 0.25.1 and beyond results in an error: TypeError: undefined is not a non-null object (Firefox) and TypeError: Object.defineProperty called on non-object (Chrome)

Environment

  • browsers and versions: Chrome 108.0.5359.94, Firefox 107.0
  • operating system: Mac OS 12.1
  • Excalibur versions: ^0.25.1
  • Works on 0.25.0 and older.

Current Workaround

N/A

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
eonarheimcommented, Dec 14, 2022

@kamranayub Any initial ideas?

0reactions
kamranayubcommented, Dec 16, 2022

I’ve also updated the CodeSandbox so it’s working with this change.

@eonarheim Not sure what to do about this issue – UMD bundle will work fine, ESM works fine (I’m pretty sure) in other native ESM environments. So we may want to add a prominent note about Next.js support, or perhaps create a next-excalibur-plugin with a similar withExcalibur HOC like Preact does to wrap this logic (as having static file paths creates a coupling to our internals).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · excaliburjs/Excalibur - GitHub
Dynamic import() broken on Excalibur 0.25.1 and newer. ... ProTip! Find all open issues with in progress development work with linked:pr. Footer.
Read more >
Dynamic Imports: Auto Repairs Tempe & Gilbert, Arizona (AZ)
Dynamic Imports provides top quality and professional auto repair services in Tempe and Gilbert, Arizona (AZ). Call us at 480-557-8868 for more details....
Read more >
babel-plugin-syntax-dynamic-import does not transpile
Its running on the client, so I would not need dynamic-import-node. However, I tried it again, and it does not change anything. –...
Read more >
Webpack and Dynamic Imports: Doing it Right - Medium
As the import is a function receiving a string, we can do powerful things like loading modules using expressions. Dynamic module loading with...
Read more >
Fixing WebpackChunkName for Dynamic Imports - Time to Hack
The First line of the Readme of the repo: Babel plugin to transpile import() to require.ensure , for Webpack. And this is what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found