Dynamic import() broken on Excalibur 0.25.1 and newer.
See original GitHub issueSteps 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:
- Created 10 months ago
- Comments:7 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kamranayub Any initial ideas?
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 similarwithExcalibur
HOC like Preact does to wrap this logic (as having static file paths creates a coupling to our internals).