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

import.meta.url undefined #36

Open
LangLangBart opened this issue Apr 24, 2023 · 0 comments
Open

import.meta.url undefined #36

LangLangBart opened this issue Apr 24, 2023 · 0 comments

Comments

@LangLangBart
Copy link

LangLangBart commented Apr 24, 2023

to reproduce

  • create a folder and install @digitak/esrun
  • add type:module to your package.json
{
	"type": "module",
	"dependencies": {
		"@digitak/esrun": "^3.2.24",
	}
}
  • create a test.ts file with one line console.log(import.meta.url)
  • run the file with esrun, notice the output is undefined
node_modules/.bin/esrun test.ts
# undefined

expected result

  • install esbuild and run the test.ts with esbuild
  • the output is correct
node_modules/.bin/esbuild test.ts --bundle --format=esm --platform=node --outfile=build.js --loader:.ts=ts
node build.js
# file:///Users/paria/Developer/esrun_test/build.js

workaround

additional notes

  • node v20.0.0
  • @digitak/esrun ^3.2.24 (3.2.25 is not available via npm)
  • esbuild ^0.17.18
  • If I use the VSCode debugger with these settings in my launch.json the output is also correct. It uses esbuild-register, can esrun also be used for this task, then I would need one dependency less in my setup?
{
    "configurations": [
        {
            "console": "integratedTerminal",
            "name": "Debug TypeScript",
            "program": "${file}",
            "request": "launch",
            "runtimeArgs": [
                // https://github.com/egoist/esbuild-register#experimental-loader-support
                "--loader",
                "esbuild-register/loader",
                "--no-warnings",
                "--require",
                "esbuild-register"
            ],
            "smartStep": true,
            "stopOnEntry": true,
            "type": "node"
        }
    ]
}

related

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

1 participant