lukehaas / RunJS

RunJS is a JavaScript playground for macOS, Windows and Linux. Write code with instant feedback and access to Node.js and browser APIs.
https://runjs.app
2k stars 43 forks source link

Cannot import bundled package with alias `* as alias` #614

Closed brandonmcconnell closed 2 months ago

brandonmcconnell commented 3 months ago

I've been getting this issue for about a month. Even with bundling enabled in my RunJS settings, I get the error below when importing * as alias.

TypeError: Cannot set property top of #<Window> which has only a getter

For example:

import * as d3 from 'd3'

d3.format(".2s")(42e6)

Debug log

{ "version": "2.11.0", "platform": "darwin", "arch": "arm64", "activated": true, "logs": [ { "path": "/Users/brandonmcconnell/Library/Logs/runjs/main.log", "lines": [ "[2024-03-18 22:43:08.335] [error] Unhandled TypeError: Cannot read properties of undefined (reading 'libraryDefaultDir')", " at Function.resolvePathFn (/Applications/RunJS.app/Contents/Resources/app.asar/entry-bundle.js:14:97807)", " at Function.readAllLogs (/Applications/RunJS.app/Contents/Resources/app.asar/entry-bundle.js:14:97314)", " at click (/Applications/RunJS.app/Contents/Resources/app.asar/entry-bundle.js:8:90678)", " at MenuItem.click (node:electron/js2c/browser_init:2:29559)", " at a._executeCommand (node:electron/js2c/browser_init:2:34987)", "" ] } ] }

lukehaas commented 3 months ago

@brandonmcconnell thanks for raising this. It looks like you can resolve this problem by disabling transpilation. I'm not certain why that is at the moment but I'll have a closer look soon.

lukehaas commented 2 months ago

@brandonmcconnell this looks like it's working now in the latest release. Version 2.12.0.

brandonmcconnell commented 2 months ago

Thanks!

brandonmcconnell commented 2 months ago

I'll close this for now and open a new one if I encounter the same issue, or one similar, again.