deno bundle <JavaScript file with triple-slash directive>

Created on 31 Mar 2020  Â·  6Comments  Â·  Source: denoland/deno

Steps to reproduce

Run deno bundle https://deno.land/x/once/index.js

Expected behavior

It prints a bundled JavaScript code

Actual behavior

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.

bug cli

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 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.

All 6 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sh7dm picture sh7dm  Â·  3Comments

JosephAkayesi picture JosephAkayesi  Â·  3Comments

somombo picture somombo  Â·  3Comments

watilde picture watilde  Â·  3Comments

ry picture ry  Â·  3Comments