jodinathan / typings

Apache License 2.0
38 stars 9 forks source link

Problems running build_runner command even with no repository changes #6

Closed tylandercasper closed 11 months ago

tylandercasper commented 1 year ago

I'm trying to play around with the tool and am having difficulties getting it to do anything.

running the command: dart run --enable-asserts --enable-experiment="inline-class" build_runner build --enable-experiment="inline-class"

generates:

[INFO] Generating build script completed, took 318ms
[INFO] Precompiling build script... completed, took 6.8s
[INFO] Building new asset graph completed, took 1.1s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Generating SDK summary completed, took 3.8s
[WARNING] No actions completed for 31.4s, waiting on:
  - typings:coregenerator on lib/core.dart

[INFO] Files:
 - out/package/lib/lib.es5.d.ts
 - out/package/lib/lib.es2015.core.d.ts
 - out/package/lib/lib.es2015.collection.d.ts
 - out/package/lib/lib.es2015.iterable.d.ts
 - out/package/lib/lib.es2015.generator.d.ts
 - out/package/lib/lib.es2015.promise.d.ts
 - out/package/lib/lib.es2015.proxy.d.ts
 - out/package/lib/lib.es2015.reflect.d.ts
 - out/package/lib/lib.es2015.symbol.d.ts
 - out/package/lib/lib.es2015.symbol.wellknown.d.ts
 - out/package/lib/lib.es2016.array.include.d.ts
 - out/package/lib/lib.es2017.object.d.ts
 - out/package/lib/lib.es2017.sharedmemory.d.ts
 - out/package/lib/lib.es2017.string.d.ts
 - out/package/lib/lib.es2017.intl.d.ts
 - out/package/lib/lib.es2017.typedarrays.d.ts
 - out/package/lib/lib.es2018.asynciterable.d.ts
 - out/package/lib/lib.es2018.asyncgenerator.d.ts
 - out/package/lib/lib.es2018.promise.d.ts
 - out/package/lib/lib.es2018.regexp.d.ts
 - out/package/lib/lib.es2018.intl.d.ts
 - out/package/lib/lib.es2019.array.d.ts
 - out/package/lib/lib.es2019.object.d.ts
 - out/package/lib/lib.es2019.string.d.ts
 - out/package/lib/lib.es2019.symbol.d.ts
 - out/package/lib/lib.es2019.intl.d.ts
 - out/package/lib/lib.es2020.bigint.d.ts
 - out/package/lib/lib.es2020.date.d.ts
 - out/package/lib/lib.es2020.number.d.ts
 - out/package/lib/lib.es2020.promise.d.ts
 - out/package/lib/lib.es2020.sharedmemory.d.ts
 - out/package/lib/lib.es2020.string.d.ts
 - out/package/lib/lib.es2020.symbol.wellknown.d.ts
 - out/package/lib/lib.es2020.intl.d.ts
 - out/package/lib/lib.es2021.intl.d.ts
 - out/package/lib/lib.es2021.promise.d.ts
 - out/package/lib/lib.es2021.string.d.ts
 - out/package/lib/lib.es2021.weakref.d.ts
 - out/package/lib/lib.es2022.array.d.ts
 - out/package/lib/lib.es2022.error.d.ts
 - out/package/lib/lib.es2022.intl.d.ts
 - out/package/lib/lib.es2022.object.d.ts
 - out/package/lib/lib.es2022.regexp.d.ts
 - out/package/lib/lib.es2022.sharedmemory.d.ts
 - out/package/lib/lib.es2023.array.d.ts
 - out/package/lib/lib.dom.d.ts
 - out/package/lib/lib.webworker.importscripts.d.ts
 - out/package/lib/lib.scripthost.d.ts
[WARNING] typings:coregenerator on lib/core.dart:
TYPINGS BUILD ERROR: ProcessException: The system cannot find the file specified.

  Command: ts-node G:\Programming\typings\typings/../ts_ast/src/index.ts out/package/lib/lib.es5.d.ts out/package/lib/lib.es2015.core.d.ts out/package/lib/lib.es2015.collection.d.ts out/package/lib/lib.es2015.iterable.d.ts out/package/lib/lib.es2015.generator.d.ts out/package/lib/lib.es2015.promise.d.ts out/package/lib/lib.es2015.proxy.d.ts out/package/lib/lib.es2015.reflect.d.ts out/package/lib/lib.es2015.symbol.d.ts out/package/lib/lib.es2015.symbol.wellknown.d.ts out/package/lib/lib.es2016.array.include.d.ts out/package/lib/lib.es2017.object.d.ts out/package/lib/lib.es2017.sharedmemory.d.ts out/package/lib/lib.es2017.string.d.ts out/package/lib/lib.es2017.intl.d.ts out/package/lib/lib.es2017.typedarrays.d.ts out/package/lib/lib.es2018.asynciterable.d.ts out/package/lib/lib.es2018.asyncgenerator.d.ts out/package/lib/lib.es2018.promise.d.ts out/package/lib/lib.es2018.regexp.d.ts out/package/lib/lib.es2018.intl.d.ts out/package/lib/lib.es2019.array.d.ts out/package/lib/lib.es2019.object.d.ts out/package/lib/lib.es2019.string.d.ts out/package/lib/lib.es2019.symbol.d.ts out/package/lib/lib.es2019.intl.d.ts out/package/lib/lib.es2020.bigint.d.ts out/package/lib/lib.es2020.date.d.ts out/package/lib/lib.es2020.number.d.ts out/package/lib/lib.es2020.promise.d.ts out/package/lib/lib.es2020.sharedmemory.d.ts out/package/lib/lib.es2020.string.d.ts out/package/lib/lib.es2020.symbol.wellknown.d.ts out/package/lib/lib.es2020.intl.d.ts out/package/lib/lib.es2021.intl.d.ts out/package/lib/lib.es2021.promise.d.ts out/package/lib/lib.es2021.string.d.ts out/package/lib/lib.es2021.weakref.d.ts out/package/lib/lib.es2022.array.d.ts out/package/lib/lib.es2022.error.d.ts out/package/lib/lib.es2022.intl.d.ts out/package/lib/lib.es2022.object.d.ts out/package/lib/lib.es2022.regexp.d.ts out/package/lib/lib.es2022.sharedmemory.d.ts out/package/lib/lib.es2023.array.d.ts out/package/lib/lib.dom.d.ts out/package/lib/lib.webworker.importscripts.d.ts out/package/lib/lib.scripthost.d.ts
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:401:33)
#1      Process.start (dart:io-patch/process_patch.dart:38:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:578:18)
#3      Process.run (dart:io-patch/process_patch.dart:49:12)
#4      Transpiler._createProject (package:ts2dart/src/transpiler.dart:48:29)
#5      Transpiler.fromNpm (package:ts2dart/src/transpiler.dart:178:24)
<asynchronous suspension>
#6      TypingsBuilder.build (package:typings/tool/build.dart:56:15)
<asynchronous suspension>
#7      runBuilder.buildForInput (package:build/src/generate/run_builder.dart:83:7)
<asynchronous suspension>
#8      Future.wait.<anonymous closure> (dart:async/future.dart:525:21)
<asynchronous suspension>

[SEVERE] typings:coregenerator on lib/core.dart:

ProcessException: The system cannot find the file specified.

  Command: ts-node G:\Programming\typings\typings/../ts_ast/src/index.ts out/package/lib/lib.es5.d.ts out/package/lib/lib.es2015.core.d.ts out/package/lib/lib.es2015.collection.d.ts out/package/lib/lib.es2015.iterable.d.ts out/package/lib/lib.es2015.generator.d.ts out/package/lib/lib.es2015.promise.d.ts out/package/lib/lib.es2015.proxy.d.ts out/package/lib/lib.es2015.reflect.d.ts out/package/lib/lib.es2015.symbol.d.ts out/package/lib/lib.es2015.symbol.wellknown.d.ts out/package/lib/lib.es2016.array.include.d.ts out/package/lib/lib.es2017.object.d.ts out/package/lib/lib.es2017.sharedmemory.d.ts out/package/lib/lib.es2017.string.d.ts out/package/lib/lib.es2017.intl.d.ts out/package/lib/lib.es2017.typedarrays.d.ts out/package/lib/lib.es2018.asynciterable.d.ts out/package/lib/lib.es2018.asyncgenerator.d.ts out/package/lib/lib.es2018.promise.d.ts out/package/lib/lib.es2018.regexp.d.ts out/package/lib/lib.es2018.intl.d.ts out/package/lib/lib.es2019.array.d.ts out/package/lib/lib.es2019.object.d.ts out/package/lib/lib.es2019.string.d.ts out/package/lib/lib.es2019.symbol.d.ts out/package/lib/lib.es2019.intl.d.ts out/package/lib/lib.es2020.bigint.d.ts out/package/lib/lib.es2020.date.d.ts out/package/lib/lib.es2020.number.d.ts out/package/lib/lib.es2020.promise.d.ts out/package/lib/lib.es2020.sharedmemory.d.ts out/package/lib/lib.es2020.string.d.ts out/package/lib/lib.es2020.symbol.wellknown.d.ts out/package/lib/lib.es2020.intl.d.ts out/package/lib/lib.es2021.intl.d.ts out/package/lib/lib.es2021.promise.d.ts out/package/lib/lib.es2021.string.d.ts out/package/lib/lib.es2021.weakref.d.ts out/package/lib/lib.es2022.array.d.ts out/package/lib/lib.es2022.error.d.ts out/package/lib/lib.es2022.intl.d.ts out/package/lib/lib.es2022.object.d.ts out/package/lib/lib.es2022.regexp.d.ts out/package/lib/lib.es2022.sharedmemory.d.ts out/package/lib/lib.es2023.array.d.ts out/package/lib/lib.dom.d.ts out/package/lib/lib.webworker.importscripts.d.ts out/package/lib/lib.scripthost.d.ts
[WARNING] typings:typesgenerator on lib/d/animejs.dart:
TYPINGS BUILD ERROR: Invalid argument(s): Illegal character in path
#0      _Uri._checkWindowsPathReservedCharacters (dart:core/uri.dart:1842:11)
#1      _Uri._makeWindowsFileUrl (dart:core/uri.dart:1935:7)
#2      new _Uri.file (dart:core/uri.dart:1809:11)
#3      FileSystemEntity.uri (dart:io/file_system_entity.dart:244:22)
#4      Transpiler.fromNpm (package:ts2dart/src/transpiler.dart:153:33)
<asynchronous suspension>
#5      TypingsBuilder.build (package:typings/tool/build.dart:56:15)
<asynchronous suspension>
#6      runBuilder.buildForInput (package:build/src/generate/run_builder.dart:83:7)
<asynchronous suspension>
#7      Future.wait.<anonymous closure> (dart:async/future.dart:525:21)
<asynchronous suspension>

[SEVERE] typings:typesgenerator on lib/d/animejs.dart:

Invalid argument(s): Illegal character in path
[INFO] Files:
 - G:\Programming\typings\typings/work/deno/download/0lib.deno.d.ts
[WARNING] typings:typesgenerator on lib/d/deno.dart:
TYPINGS BUILD ERROR: ProcessException: The system cannot find the file specified.

  Command: ts-node G:\Programming\typings\typings/../ts_ast/src/index.ts G:\Programming\typings\typings/work/deno/download/0lib.deno.d.ts
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:401:33)
#1      Process.start (dart:io-patch/process_patch.dart:38:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:578:18)
#3      Process.run (dart:io-patch/process_patch.dart:49:12)
#4      Transpiler._createProject (package:ts2dart/src/transpiler.dart:48:29)
#5      Transpiler.fromUrls (package:ts2dart/src/transpiler.dart:221:24)
<asynchronous suspension>
#6      TypingsBuilder.build (package:typings/tool/build.dart:78:15)
<asynchronous suspension>
#7      runBuilder.buildForInput (package:build/src/generate/run_builder.dart:83:7)
<asynchronous suspension>
#8      Future.wait.<anonymous closure> (dart:async/future.dart:525:21)
<asynchronous suspension>

[SEVERE] typings:typesgenerator on lib/d/deno.dart:

ProcessException: The system cannot find the file specified.

  Command: ts-node G:\Programming\typings\typings/../ts_ast/src/index.ts G:\Programming\typings\typings/work/deno/download/0lib.deno.d.ts
[WARNING] typings:typesgenerator on lib/d/inputmask.dart:
TYPINGS BUILD ERROR: Invalid argument(s): Illegal character in path
#0      _Uri._checkWindowsPathReservedCharacters (dart:core/uri.dart:1842:11)
#1      _Uri._makeWindowsFileUrl (dart:core/uri.dart:1935:7)
#2      new _Uri.file (dart:core/uri.dart:1809:11)
#3      FileSystemEntity.uri (dart:io/file_system_entity.dart:244:22)
#4      Transpiler.fromNpm (package:ts2dart/src/transpiler.dart:153:33)
<asynchronous suspension>
#5      TypingsBuilder.build (package:typings/tool/build.dart:56:15)
<asynchronous suspension>
#6      runBuilder.buildForInput (package:build/src/generate/run_builder.dart:83:7)
<asynchronous suspension>
#7      Future.wait.<anonymous closure> (dart:async/future.dart:525:21)
<asynchronous suspension>

[SEVERE] typings:typesgenerator on lib/d/inputmask.dart:

Invalid argument(s): Illegal character in path
[WARNING] No actions completed for 36.2s, waiting on:
  - typings:typesgenerator on lib/d/gojs.dart

[INFO] Files:
 - out/package/release/go.d.ts
[WARNING] typings:typesgenerator on lib/d/gojs.dart:
TYPINGS BUILD ERROR: ProcessException: The system cannot find the file specified.

  Command: ts-node G:\Programming\typings\typings/../ts_ast/src/index.ts out/package/release/go.d.ts
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:401:33)
#1      Process.start (dart:io-patch/process_patch.dart:38:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:578:18)
#3      Process.run (dart:io-patch/process_patch.dart:49:12)
#4      Transpiler._createProject (package:ts2dart/src/transpiler.dart:48:29)
#5      Transpiler.fromNpm (package:ts2dart/src/transpiler.dart:178:24)
<asynchronous suspension>
#6      TypingsBuilder.build (package:typings/tool/build.dart:56:15)
<asynchronous suspension>
#7      runBuilder.buildForInput (package:build/src/generate/run_builder.dart:83:7)
<asynchronous suspension>
#8      Future.wait.<anonymous closure> (dart:async/future.dart:525:21)
<asynchronous suspension>

[SEVERE] typings:typesgenerator on lib/d/gojs.dart:

ProcessException: The system cannot find the file specified.

  Command: ts-node G:\Programming\typings\typings/../ts_ast/src/index.ts out/package/release/go.d.ts
[INFO] Running build completed, took 1m 18s
[INFO] Caching finalized dependency graph completed, took 189ms
[SEVERE] Failed after 1m 19s

Let me know if there's anything I can change. I'm very excited to see what the updated version of jsbindings can do!

tylandercasper commented 1 year ago

looking into it a bit more and it seems like the file references aren't correct. It says "out/package/...." but the files they're referencing are in "work/PACKAGENAME/out/package/..."

oddly enough the deno one fails even though it's a fully qualified path, but if I copy and paste the command line it goes through fine.

jodinathan commented 1 year ago

I think it is related to file path indeed. I use a mac so it should work on mac and linux users.

Maybe there is a way to generate more agnostic paths

tylandercasper commented 1 year ago

I tried running it on my mac, and it's still not working but with a different issue: With dart 3.0.7 I get this output: output.txt

What version of dart are you using, and is there a recommended location I should put your files in.

tylandercasper commented 1 year ago

Good news: Got it to run in Windows. Turns out Processs.Run just needs to be passed runInShell:true.

There was another issue with invalid characters in path, but I was able to resolve that by converting from File(path) to URL.parse(path).

Here's the patch file: windows.patch

Bad news is I'm still getting the same issues as I was getting on the mac.

If I comment out the @Typings.npm line in core.dart than I have a little bit more success. All of them work except for lib/d/inputmask.dart.

Unfortunately the project I was hoping to convert still doesn't work. Before I dig into why, I'd really like to figure out why even the default setup isn't building for me.

jodinathan commented 1 year ago

Today is holiday here in Brazil so I will probably be back on monday or maybe tomorrow then I try to help. What is the package you are trying to build?

tylandercasper commented 1 year ago

"@types/vscode" which can be pulled from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/vscode or https://github.com/microsoft/vscode/blob/main/src/vscode-dts/vscode.d.ts

not sure which one is better.

Thanks again for your help

jodinathan commented 1 year ago

pushed a commit to master with the vscode bindings

@tylandercasper can you do some usage testings before I publish it please.

tylandercasper commented 1 year ago

hey thanks man. I just got off of work, but I'll play with it tomorrow and let you know.

tylandercasper commented 1 year ago

unfortunately it looks like I may have wasted your time. vscode uses node and dart compile js doesn't support outputting modules. before I can even run your code I'm getting compile issues like "self" is undefined and output issues like "import 'package:typings/d/vscode/vscode_commands.dart' as vscode_commands;" creating js like vscode.commands.vscode.commands

even fixing the superficial issues it still breaks when a command is actually run.

[Main Instruction]
Command 'Hello World' resulted in an error

[Content]
NoSuchMethodError: method not found: 'call'
Receiver: Closure '__activateVs_closure'
Arguments: []

If that error means something to you and have an easy fix I'll take it, but otherwise I feel like this is out of scope for your project.

Thanks so much for looking into it for me though. I really appreciate it and I love what you're trying to do here.

jodinathan commented 1 year ago

I guess I can take a look when I get some free time.
I would need a simple repro of a working JS file and how to test it

tylandercasper commented 1 year ago

Hey if you're looking for a challenge or some kind of extreme edge case to push your tools limits, I can upload a sample for you to play with. BUT I do think there's like a 90% chance that this has nothing to do with your tool and everything to do with the fact that dart js wasn't meant to hybrid environments like vscode.

On the bright side, the latest changes plus the windows patch I included above have fixed the original issue! I can now call build_runner without any issues. So we can safely close this issue.

jodinathan commented 11 months ago

I think we can overcome these dart2js with something like https://pub.dev/packages/node_preamble.

I am just not sure how to add the js in the lib into the build system

tylandercasper commented 11 months ago

I put up a sample project up at https://github.com/tylandercasper/dart_vsplugin

The readme.md file has step by step instructions on running it.

There's also a wrapper.js if you want to throw in some extra launch logic.

If you can figure out the changes necessary to get it to work at all then it's pretty simple to make a script that modifies the output file to add those changes.

On Tue, Sep 26, 2023 at 5:38 PM Jonathan Rezende @.***> wrote:

I think we can overcome these dart2js with something like https://pub.dev/packages/node_preamble.

I am just not sure how to add the js in the lib into the build system

— Reply to this email directly, view it on GitHub https://github.com/jodinathan/typings/issues/6#issuecomment-1736397901, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZPNAF5OKKJTRZUVEUPMLX4NKOHANCNFSM6AAAAAA4K36LX4 . You are receiving this because you were mentioned.Message ID: @.***>

jodinathan commented 11 months ago

found the problem. The vscode extension is calling the callback without arguments, hence why it can't find the call signature.

Change the call to registerCommand to make its first argument optional: vscode_commands.registerCommand('dart_vscode.helloWorld', ([a]) {}

then it works

jodinathan commented 11 months ago

I will dig why it is generating vscode.window.vscode.window soon.

I will also make the signature of functions with nullable parameters to use optional parameters. I think this change will fix the call problem because it will be required the callbacks to use optional parameters

tylandercasper commented 11 months ago

wow, that was fast!

One other weird issue is that register command returns a "Disposable", but the subscriptions array is expecting an "IInline32" object, which Disposable does not implement or extend.

On Thu, Sep 28, 2023 at 10:25 AM Jonathan Rezende @.***> wrote:

I will dig why it is generating vscode.window.vscode.window soon.

I will also make the signature of functions with nullable parameters to use optional parameters. I think this change will fix the call problem because it will be required the callbacks to use optional parameters

— Reply to this email directly, view it on GitHub https://github.com/jodinathan/typings/issues/6#issuecomment-1739527007, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZPNERRXFP4YLGL5ZL5ALX4WJGLANCNFSM6AAAAAA4K36LX4 . You are receiving this because you were mentioned.Message ID: @.***>

jodinathan commented 11 months ago

publibhsed a new version with fixes:

the main.dart in the example now:

import 'package:typings/d/vscode.dart' as vscode;
import 'package:typings/d/vscode/vscode_commands.dart' as vscode_commands;
import 'package:typings/d/vscode/vscode_window.dart' as vscode_window;

void activate(vscode.ExtensionContext context) {
  // Use the console to output diagnostic information (console.log) and errors (console.error)
  // This line of code will only be executed once when your extension is activated
  print('Congratulations, your extension "dart_vscode" is now active!');

  // The command has been defined in the package.json file
  // Now provide the implementation of the command with  registerCommand
  // The commandId parameter must match the command field in package.json
  var disposable =
      vscode_commands.registerCommand('dart_vscode.helloWorld', ([a]) {
    // The code you place here will be executed every time your command is executed

    // Display a message box to the user
    vscode_window.showInformationMessage.$1('Hello World from dart_vscode!');
  });

  context.subscriptions.add(disposable);
}

void main() {
  vscode.module.exports = vscode.ModuleExports(activate: activate);
}

I am closing this issue as this is fixed but please feel free to open a new one if you find anything.

Also, please, consider donating if it is an affordable option to you. Raising a family in Brazil is just way too difficult.