Run deno bundle https://deno.land/x/once/index.js
It prints a bundled JavaScript code
error TS5012: Cannot read file 'https://deno.land/x/once/index.js': Error: assert.
â–º
error TS6053: File 'https://deno.land/x/once/index.js' not found.
â–º
Found 2 errors.
I didn't try to bundle remote URL at first, instead, I tried bundling a local file (deps.ts) that import remote JS file. No compile errors occur, but a runtime error (cannot read property of undefined) was thrown when attempting to run it in the browser and in Node.js.
This doesn't have anything to do with it being remote. The bug is related to trying to bundle a JavaScript file with a /// <reference types="..." /> directive (and I suspect would also occur with ones where a X-TypeScript-Types header is supplied. In these situations we replace the .js with the .d.ts file when we feed it to the compiler, but then the compiler can't access the .js file to generate the bundle.
@kitsonk I have changed the title of this issue because I trust what you said.
Hi,
Are there any updates on this?
No.
I suspect would also occur with ones where a X-TypeScript-Types header is supplied
It does look like this happens when using the X-TypeScript-Types header. For example, using skypack:
import { h, render } from "https://cdn.skypack.dev/preact@^10.4.4?dts";
render(h('div', null, 'hello world'), document.body);
// tsconfig.json
{
"compilerOptions": {
"jsx": "react",
"jsxFactory": "h",
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
]
}
}
deno bundle -c tsconfig.json ./app.ts ./app.bundle.js
The bundle is missing Preact, but works fine if you remove the ?dts query param.
This was fixed in Deno 1.5
Most helpful comment
This doesn't have anything to do with it being remote. The bug is related to trying to bundle a JavaScript file with a
/// <reference types="..." />directive (and I suspect would also occur with ones where aX-TypeScript-Typesheader is supplied. In these situations we replace the.jswith the.d.tsfile when we feed it to the compiler, but then the compiler can't access the.jsfile to generate the bundle.