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

v64 breaks Deno bundling with protobufjs #256

Closed
ObsidianX opened this issue Jan 24, 2022 · 7 comments
Closed

v64 breaks Deno bundling with protobufjs #256

ObsidianX opened this issue Jan 24, 2022 · 7 comments

Comments

@ObsidianX
Copy link

According to the changelog build v64 updated the way process is handled. As a result the Deno version of protobufjs includes https://deno.land/[email protected]/node/process.ts which includes unstable APIs and cannot be used without adding the --unstable flag to all Deno commands.


Sample file:

// test.ts
import 'https://esm.sh/protobufjs';

Result:

$ deno cache test.ts
# ...
Check file:///tmp/test.ts
error: TS2339 [ERROR]: Property 'setRaw' does not exist on type 'typeof Deno'. 'Deno.setRaw' is an unstable API. Did you forget to run with the '--unstable' flag?
  Deno.setRaw?.(Deno.stdin?.rid, enable);
       ~~~~~~
    at https://deno.land/[email protected]/node/_process/streams.ts:65:8

TS2339 [ERROR]: Property 'addSignalListener' does not exist on type 'typeof Deno'. 'Deno.addSignalListener' is an unstable API. Did you forget to run with the '--unstable' flag?
      Deno.addSignalListener(event as Deno.Signal, listener);
           ~~~~~~~~~~~~~~~~~
    at https://deno.land/[email protected]/node/process.ts:285:12

TS2339 [ERROR]: Property 'removeSignalListener' does not exist on type 'typeof Deno'. 'Deno.removeSignalListener' is an unstable API. Did you forget to run with the '--unstable' flag?
      Deno.removeSignalListener(event as Deno.Signal, listener);
           ~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/[email protected]/node/process.ts:303:12

TS2339 [ERROR]: Property 'umask' does not exist on type 'typeof Deno'. 'Deno.umask' is an unstable API. Did you forget to run with the '--unstable' flag?
  umask = Deno.umask;
               ~~~~~
    at https://deno.land/[email protected]/node/process.ts:384:16

Found 4 errors.

If --unstable is provided then it will succeed, but attempting to generate a CommonJS bundle from the result fails for another reason:

$ esbuild test.js --format=cjs --outfile=test.esbuild.js
✘ [ERROR] Top-level await is currently not supported with the "cjs" output format

    test.js:10897:13:
      10897 │     state = (await Deno.permissions.query({
            ╵              ~~~~~

1 error

Pinning version v63 fixes both of the above errors:

// test.ts
import 'https://esm.sh/protobufjs?pin=v63';
$ deno bundle test.ts -- test.js
Check file:///tmp/test.ts
Bundle file:///tmp/test.ts
Emit "test.js" (140.55KB)
$ esbuild test.js --format=cjs --outfile=test.esbuild.js

  test.esbuild.js  127.2kb

⚡ Done in 14ms

Test to verify it's the inclusion of process:

// test.ts
import 'https://deno.land/[email protected]/node/process.ts';
$ deno cache test.ts
Check file:///tmp/test.ts
error: TS2339 [ERROR]: Property 'setRaw' does not exist on type 'typeof Deno'. 'Deno.setRaw' is an unstable API. Did you forget to run with the '--unstable' flag?
  Deno.setRaw?.(Deno.stdin?.rid, enable);
       ~~~~~~
    at https://deno.land/[email protected]/node/_process/streams.ts:65:8

TS2339 [ERROR]: Property 'addSignalListener' does not exist on type 'typeof Deno'. 'Deno.addSignalListener' is an unstable API. Did you forget to run with the '--unstable' flag?
      Deno.addSignalListener(event as Deno.Signal, listener);
           ~~~~~~~~~~~~~~~~~
    at https://deno.land/[email protected]/node/process.ts:285:12

TS2339 [ERROR]: Property 'removeSignalListener' does not exist on type 'typeof Deno'. 'Deno.removeSignalListener' is an unstable API. Did you forget to run with the '--unstable' flag?
      Deno.removeSignalListener(event as Deno.Signal, listener);
           ~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/[email protected]/node/process.ts:303:12

TS2339 [ERROR]: Property 'umask' does not exist on type 'typeof Deno'. 'Deno.umask' is an unstable API. Did you forget to run with the '--unstable' flag?
  umask = Deno.umask;
               ~~~~~
    at https://deno.land/[email protected]/node/process.ts:384:16

Found 4 errors.
@Xeevis
Copy link

Xeevis commented Jan 24, 2022

I think I also have problem with mentioned change, this works fine

import mapboxgl from "https://esm.sh/[email protected]?pin=v63";

but this throws

import mapboxgl from "https://esm.sh/[email protected]?pin=v64";
X [ERROR] Expected "from" but found "{"

    deno-url:https://deno.land/[email protected]/node/process.ts:36:12:       
      36  import type { BindingName } from "./internal_binding/mod.ts";
                      ^
                      from

fatal error: error: Uncaught (in promise) Error: Build failed with 1 error:
deno-url:https://deno.land/[email protected]/node/process.ts:36:12: ERROR: Expected "from" but found "{"
  let error = new Error(`${text}${summary}`);
              ^
    at failureErrorWithLog (https://deno.land/x/[email protected]/mod.js:1521:15)
    at https://deno.land/x/[email protected]/mod.js:1179:28
    at runOnEndCallbacks (https://deno.land/x/[email protected]/mod.js:967:63)
    at buildResponseToResult (https://deno.land/x/[email protected]/mod.js:1177:7)
    at https://deno.land/x/[email protected]/mod.js:1286:14
    at https://deno.land/x/[email protected]/mod.js:599:9
    at handleIncomingPacket (https://deno.land/x/[email protected]/mod.js:696:9)
    at readFromStdout (https://deno.land/x/[email protected]/mod.js:566:7)
    at https://deno.land/x/[email protected]/mod.js:1794:11
The terminal process "C:\Users\Xeevis\.dev\deno.EXE 'run', '--allow-all', '--unstable', 'build.ts'" terminated with exit code: 1.

@ije
Copy link
Member

ije commented Jan 25, 2022

if you are bundling code for browsers or nodejs, try to use https://esm.sh/PACKAGE?target=2021 instead

@ObsidianX
Copy link
Author

Swapping

import 'https://esm.sh/protobufjs?pin=v63';

to

import 'https://esm.sh/protobufjs?target=2021';

Produces the same problems as before. https://deno.land/[email protected]/node/process.ts is still included.

@Xeevis
Copy link

Xeevis commented Jan 26, 2022

Same issue here as well. @ije should the query string take absolute priority? Because it appears that is not the case. Deno will cache "deno production" build every single time from within VS Code, ?target makes no difference whatsoever.

Starting Deno language server...
  version: 1.18.0 (release, x86_64-pc-windows-msvc)
  executable: C:\Users\Xeevis\.dev\deno.EXE
Connected to "Visual Studio Code" 1.63.2
Enabling import suggestions for: https://deno.land
Enabling import suggestions for: https://x.nest.land
Download https://x.nest.land/.well-known/deno-import-intellisense.json
Download https://intellisense.nest.land/deno-import-intellisense.json
Enabling import suggestions for: https://crux.land
language server initialized
Server ready.
+ Download https://esm.sh/[email protected]?target=es2021
- Download https://cdn.esm.sh/v64/[email protected]/deno/mapbox-gl.js
Download https://cdn.esm.sh/v64/@types/[email protected]/index.d.ts
Download https://deno.land/[email protected]/node/process.ts
Download https://cdn.esm.sh/v64/@types/[email protected]/index.d.ts
Download https://deno.land/[email protected]/node/_errors.ts
Download https://deno.land/[email protected]/node/_options.ts

@ije ije closed this as completed in 241bd02 Jan 27, 2022
@ije
Copy link
Member

ije commented Jan 27, 2022

sorry, my mistake! please use ?target=es2015 to ?target=es2021

import 'https://esm.sh/protobufjs?target=es2021';

@Xeevis
Copy link

Xeevis commented Jan 27, 2022

sorry, my mistake! please use ?target=es2015 to ?target=es2021

import 'https://esm.sh/protobufjs?target=es2021';

It loads es2021 now, but I've also lost intellisense, with ?target=es2021 it's not downloading any types unlike ?target=deno any way to solve this?

@ije
Copy link
Member

ije commented Jan 27, 2022

It loads es2021 now, but I've also lost intellisense, with ?target=es2021 it's not downloading any types unlike ?target=deno any way to solve this?

@Xeevis just fixed it!

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

3 participants