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

deno bundle <JavaScript file with triple-slash directive> #4539

Closed
KSXGitHub opened this issue Mar 31, 2020 · 6 comments
Closed

deno bundle <JavaScript file with triple-slash directive> #4539

KSXGitHub opened this issue Mar 31, 2020 · 6 comments
Labels
bug Something isn't working correctly cli related to cli/ dir

Comments

@KSXGitHub
Copy link
Contributor

KSXGitHub commented Mar 31, 2020

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.

@kitsonk
Copy link
Contributor

kitsonk commented Mar 31, 2020

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.

@KSXGitHub KSXGitHub changed the title deno bundle <Remote JavaScript URL> deno bundle <JavaScript file with triple-slash directive> Mar 31, 2020
@KSXGitHub
Copy link
Contributor Author

@kitsonk I have changed the title of this issue because I trust what you said.

@quaos
Copy link

quaos commented Aug 30, 2020

Hi,
Are there any updates on this?

@kitsonk
Copy link
Contributor

kitsonk commented Aug 30, 2020

No.

@matt-allan
Copy link

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.

@kitsonk
Copy link
Contributor

kitsonk commented Nov 5, 2020

This was fixed in Deno 1.5

@kitsonk kitsonk closed this as completed Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir
Projects
None yet
Development

No branches or pull requests

5 participants