Code Monkey home page Code Monkey logo

node-interop's Introduction

Node interop libraries for Dart

Package Description
node_interop Node API bindings and utilities.
node_io Wrapper around Node I/O APIs designed to server as direct replacement for dart:io.
node_http HTTP client which uses Node I/O and implements package:http interface.
build_node_compilers DDC and dart2js builders to use with build_runner for compiling to Node.

node-interop's People

Contributors

alextekartik avatar awjin avatar cretezy avatar gitter-badger avatar grundid avatar jakemac53 avatar jathak avatar kevmoo avatar lexaknyazev avatar m1-nann avatar nex3 avatar pulyaevskiy avatar tvolkert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-interop's Issues

build_node_compilers is currently incompatible with Angular 5-alpha

This is related to angulardart/angular#1006 (cc @matanlurey @kwalrath)

Note that the latest version of x is incompatible with Angular 5-alpha:

> pub get
Resolving dependencies...
Because no versions of angular_test match >2.0.0-alpha+7 <3.0.0 and angular_test >=1.0.1
  <2.0.0-alpha+3 depends on args ^0.13.7, angular_test >=1.0.1 <2.0.0-alpha+3 or >2.0.0-alpha+7
  <3.0.0 requires args ^0.13.7.
And because angular_test >=2.0.0-alpha+3 <2.0.0-alpha+4 depends on angular ^5.0.0-alpha+5 and
  build_runner >=0.7.12 depends on args ^1.4.0, if build_runner >=0.7.12 and angular_test >=1.0.1
  <2.0.0-alpha+4 or >2.0.0-alpha+7 <3.0.0 then angular ^5.0.0-alpha+5.
And because angular_test >=2.0.0-alpha+4 <2.0.0-alpha+5 depends on angular ^5.0.0-alpha+6 and
  angular_test >=2.0.0-alpha+5 <2.0.0-alpha+7 depends on angular ^5.0.0-alpha+7, if build_runner
  >=0.7.12 and angular_test >=1.0.1 <2.0.0-alpha+7 or >2.0.0-alpha+7 <3.0.0 then angular
  ^5.0.0-alpha+5.
And because angular_test 2.0.0-alpha+7 depends on angular ^5.0.0-alpha+9 which depends on analyzer
  ^0.31.0+1, if build_runner >=0.7.12 and angular_test >=1.0.1 <3.0.0 then analyzer ^0.31.0+1 or
  angular ^5.0.0-alpha+9.
And because no versions of angular match >5.0.0-alpha+9 <6.0.0 and angular 5.0.0-alpha+9 depends
  on analyzer ^0.31.0+1, if build_runner >=0.7.12 and angular_test >=1.0.1 <3.0.0 then analyzer
  ^0.31.0+1.
And because every version of build_node_compilers depends on analyzer ^0.30.0 and
  angular_tour_of_heroes depends on build_runner ^0.8.0, angular_test >=1.0.1 <3.0.0 is incompatible
  with build_node_compilers.
So, because angular_tour_of_heroes depends on both build_node_compilers ^0.1.1 and angular_test
  ^2.0.0-alpha, version solving failed.

This is using the Dart SDK 2-dev.44.

How to use with webdev

This is more of a question than an issue: How do I use this with webdev?

Until now I had build_web_compilers in my pubspec.yaml, a web/index.html file, web/main.dart, and an index.js file to run Electron and have it show localhost:8080.

That worked great, until I tried to use node_interop. My code compiles but I get a runtime error about the module not being loaded. I presumed that is because I need to use build_node_compilers instead of build_web_compilers.

I swapped that in pubspec.yaml, and renamed the web directory to node, but when I run webdev serve node:8080 it gives error:

webdev could not run for this project.
You must have a dependency on `build_web_compilers` in `pubspec.yaml`.

If I add them both then I get this error:

Ok well I was getting an error like Could not find web/index.html or index.html, but now I get this, even after removing .dart_tool:

[SEVERE] The platform `ddc`, has already been registered.

[SEVERE] Failed to instantiate builder for collection with configuration:
{}
Unhandled exception:
Bad state: Unable to start build daemon.
#0      _handleDaemonStartup (package:build_daemon/client.dart:82:5)
<asynchronous suspension>
#1      BuildDaemonClient.connect (package:build_daemon/client.dart:183:11)
<asynchronous suspension>
#2      connectClient (package:webdev/src/daemon_client.dart:17:23)
#3      _startBuildDaemon (package:webdev/src/serve/dev_workflow.dart:25:18)
<asynchronous suspension>
#4      DevWorkflow.start (package:webdev/src/serve/dev_workflow.dart:173:24)
<asynchronous suspension>
#5      ServeCommand.run (package:webdev/src/command/serve_command.dart:138:27)
<asynchronous suspension>
#6      CommandRunner.runCommand (package:args/command_runner.dart:197:27)
<asynchronous suspension>
#7      _CommandRunner.runCommand (package:webdev/src/webdev_command_runner.dart:38:24)
<asynchronous suspension>
#8      CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#9      new Future.sync (dart:async/future.dart:222:31)
#10     CommandRunner.run (package:args/command_runner.dart:112:14)
#11     run (package:webdev/src/webdev_command_runner.dart:19:56)
#12     main (file:///Users/timh/.pub-cache/hosted/pub.dartlang.org/webdev-2.5.1/bin/webdev.dart:17:22)
<asynchronous suspension>
#13     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:303:32)
#14     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

How is this supposed to work?

HTTP POST request returns 411 status code

I am getting 411 status code reply from a http post request that is running inside a cloud function. Do I need to set Content-Length property or is this handled further down the stack? I have also tried setting transfer-encoding:chunked but that did not make any difference.

import 'package:node_http/node_http.dart' as http;
     // ....

     Map<String, String> headers = {
      'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
    };

    Map<String, String> body = {
      'redirect_uri': apiDesc.redirectEndpoint,
      'grant_type': 'authorization_code',
      'code': code
    };

    if (basicAuth && isNotNull(apiDesc.clientSecret)) {
      headers["Authorization"] = 'Basic ' +
          base64Encode(ascii.encode(Uri.encodeFull(apiDesc.clientId)
              + ':' + Uri.encodeFull(apiDesc.clientSecret)));
    } else {
      body["client_id"] = apiDesc.clientId;
      if (isNotNull(apiDesc.clientSecret))
        body["client_secret"] = apiDesc.clientSecret;
    }

    http.Response resp = await http.post(
        apiDesc.tokenEndpoint,
        headers: headers,
        body: body);

Version solving failed.

When my project depends on both build_runner ^0.10.0 and build_node_compilers ^0.1.10, version solving failed.

Because build_runner >=0.10.0 depends on build_runner_core >=0.3.0 <0.3.1 which depends on json_annotation ^1.0.0

node_preamble package?

Hello! I'm the creator of the node_preamble package, the preamble you're using in both tool/ and in the transformer for using Dart code on Node.js.

Just curious, why can't you use the node_preamble package that's on pub? Is there something with the preamble API we can change to make using the package more viable for node-interop?

If that's not possible, I'd still like to ask you to add the LICENSE from node_preamble somewhere to your repository, crediting both myself and the Dart team who made the preamble possible.

https://github.com/mbullington/node_preamble.dart/blob/master/LICENSE

I'm looking through your codebase right now, and look forward to potentially contributing in the future. Thanks!

node_io: Implement `FileSystem` from package:file

Related to dart-lang/glob#40.

Today the glob package uses node_io with a conditional export but we want to get away from that. We are switching to use the file package for all file system interactions.

If this package had an implementation of FileSystem, then it could easily plug in to glob in a clean way. This might also help some of the other issues listed for this package, if we can push more of the ecosystem towards using these general file interfaces instead of those from dart:io, then everything can be more flexible :).

Implement Process methods from dart:io

Hey, I'm using this library in the context of a firebase cloud function. I'm trying to utilise imagemagik from the cloud function. In JS this would be exec(...) and with dart:io i'd use Process.run(...). I can't find an alternative in node_io?

Thanks

Incorrect(?) behavior of dartify

In Javascript, it's possible to have an object with numeric keys:

var obj = {
  'Hello': 'World'
};
obj[1] = 'Hello';
console.log(obj);

The interesting behavior is that the numeric key is available with both a raw number and as the number as a string:

console.log(obj[1]) > "Hello"
console.log(obj['1']) > "Hello"

The dartify helper uses the JS Object.keys which will return only keys as strings. Which means the object that gets created will only ever have String keys.

This threw me for a loop because I was expected my object to have numeric keys.

Is this behavior expected?

I'm having to write a lot of .toString() to ensure I'm dealing only in strings.

build_node_compilers: build.yaml unable to set dart2js_args

I used to set them like this in build.yaml:

targets:
  $default:
    sources:
      - "lib/**"
      - "node/**"
    builders:
      build_node_compilers|entrypoint:
        options:
          compiler: dart2js
          dart2js_args:
            - --minify
            - --fast-startup

But now I get this error when I run pub run build_runner build --output=build/:

[SEVERE] build_node_compilers|entrypoint:

Invalid argument (dart2js_args): Expected a list of strings, but got a YamlList:: Instance of 'YamlList'
[SEVERE] build_node_compilers|entrypoint:
Failed to instantiate builder for <name> with configuration:
{
 "dart2js_args": [
  "--minify",
  "--fast-startup"
 ],
 "compiler": "dart2js"
}
error Command failed with exit code 78.

Consider exposing __filename

When using firebase cloud functions, the only way (I am aware of according to https://cloud.google.com/functions/docs/concepts/exec#file_system) to get the functions directory (when deployed) is to use __dirname or __filename (assuming the js file is at the root of this directory)

This is needed if you want to read a deployed filed in the functions directory.
So far looking at your bootstrap code, I was able to use:

@JS("self.location.href")
external String get filename;

Maybe there should be a more official/reliable way. Thanks!

use for doing quill delta streaming ?

Is this intended to help do the quill delta streaming for zefyr ?

I ask because i am doing the same in golang, but can see using Dart is pretty nice too.

Process.argv doesn't have a reified type

The Process.argv getter declares a reified type of List<String>, but because the array in question comes from JS, it doesn't have a reified String type argument. This causes it to throw an error at runtime when passed to pure Dart code that expects a List<String>.

Once dart-lang/sdk#30554 is fixed, it will be possible to modify the argv getter so that it casts the array when accessed from Dart. Until then, it's probably best to make the static type just List so that we get appropriate static errors.

node_io: Convert Node-style errors into Dart-style errors

One of the major API differences currently between node_io and dart:io is the errors: where dart:io throws various subclasses of IOException, node_io just throws Node.js's raw exceptions. This makes it difficult to use node_io to write error-safe code that works with both Dart and Node. It would be great if these exceptions were caught and wrapped in Dart-style exception classes to increase compatibility.

Not able to correctly import node_io/node_io.dart - some errors

The second issue/question - still new to dart

dart --version
Dart SDK version: 2.10.0-4.0.dev.flutter-0341576448 (be) (Sat Aug 8 20:25:12 2020 +0000) on "windows_x64"
There was "pub get" too

In the below main.dart file simple examples work on node.js like Hello World (just command: webdev build). I tried to import some interop packages for testing/learning. As 'package:node_interop/http.dart' as http; was imported correctly (not using it just imported) package:node_io/node_io.dart show some errors, using command webdev build:

build_web_compilers:entrypoint on web/aqueductnodejs.dart: Skipping compiling aqueductnodejs|web/aqueductnodejs.dart with dart2js because some of its
transitive libraries have sdk dependencies that not supported on this platform:

node_io|lib/src/directory.dart
node_io|lib/src/http_headers.dart
node_io|lib/src/stdout.dart
node_io|lib/src/network_interface.dart
node_io|lib/src/file.dart
node_io|lib/src/streams.dart
node_io|lib/node_io.dart
node_io|lib/src/internet_address.dart
node_io|lib/src/link.dart
node_io|lib/src/file_system_entity.dart
node_io|lib/src/http_server.dart

https://github.com/dart-lang/build/blob/master/docs/faq.md#how-can-i-resolve-skipped-compiling-warnings

Tried different imports like import 'package:node_interop/io.dart'; (seen heere https://www.youtube.com/watch?v=SFY3he2hcXM) , it doesn't work also.

my dart file
import 'dart:async';
import 'dart:convert';

import 'package:node_preamble/preamble.dart' as preamble;
import 'package:node_interop/fs.dart';
import 'package:node_interop/node.dart';
//import 'package:node_interop/io.dart';
import 'package:node_io/node_io.dart';

//import 'package:node_interop/fs.dart'; //
import 'package:node_interop/http.dart' as http;

Future main() async {
print('Server test Hello world!');
}

name: someapp
description: A simple command-line application.

version: 1.0.0

homepage: https://www.example.com

environment:
sdk: '>=2.8.1 <3.0.0'

dependencies:

path: ^1.7.0

node_preamble: ^1.4.12
node_interop: ^1.1.1
node_io: ^1.1.1
#node_io:

git:

url: https://github.com/pulyaevskiy/node-interop

path: node_io

ref: #77

dev_dependencies:
pedantic: ^1.9.0
build_runner: '>=1.6.2 <2.0.0'
build_web_compilers: '>=2.6.1 <3.0.0'

I am asking anybody for helping with this. If it is too compilcated, please don't feel obliged to waste your time. I assume it is not that difficult for experienced users with node_interop libraries. Right now just need it to work for simple tests. Don't need to reach too far.

Calling forEach on HttpHeaders crashes

Thanks a lot for your various interop libs that I'm trying to use to write firebase functions

I tried with the following test and in a firebase functions to call forEach

test('forEach', () {
  Map map = {};
  headers.forEach((key, value) {
    map[key] = value;
  });
  expect(map['content-type'], [headers.contentType.toString()]);
});

This was giving the following error:

TypeError: Cannot read property 'getHeaderNames$0' of undefined

I created a fix in a fork: https://github.com/tekartik/node-interop/commit/f604820ea4af43371d610e1f7b04485f1be6df16

Basically I simply replaced

var names = nativeResponse.getHeaderNames();

with

var names = jsObjectKeys(nativeHeaders);

This solves my issue calling forEach both in the unit test and in my firebase function.
I guess it is not sufficient as there are more places where nativeResponse is used and I'm not sure why. Let me know if you would accept a PR or whether you plan to make more changes in this area

Could a framework like Aqueduct run out of the box?

I am new to dart. Can Aqueduct framework run out of the box on node.js? As i already understand someone would have to write Aqueduct dependencies - node.js-compatible replacements, because, i see, the author had to write http package for node.js. As i assume all those tree-like-related dependencies are written in pure dart so it is not a far away idea to implement them one by one with not very, very much effort, is it? Short answer would be appreciated as much as a long one. Ofcourse too, and i quess i should'nt ask this question here.

nnbd support

Is there a plan to have support for nnbd for both the compilers and packages? Thanks!

Passing --no-source-maps dart2js flag breaks the build

targets:
  $default:
    sources:
      - "node/**"
      - "lib/**"
    builders:
      build_node_compilers|entrypoint:
        generate_for:
          - node/**.dart
        options:
          compiler: dart2js
          dart2js_args:
          - --no-source-maps
$ pub run build_runner build --release --output node:build

... after dart2js output ...
[SEVERE] build_node_compilers|entrypoint on node/node_wrapper.dart:

FileSystemException: Cannot open file, path = '<...>/node/foo.dart.js.map' (OS Error: No such file or directory, errno = 2)
[INFO] Running build completed, took 6.7s
[INFO] Caching finalized dependency graph completed, took 144ms
[SEVERE] Failed after 6.9s

Fix tests deprecation warnings

Analyzing build_node_compilers...
  hint • 'JSON' is deprecated and shouldn't be used at lib/src/dart2js_bootstrap.dart:18:36 • deprecated_member_use
  hint • 'JSON' is deprecated and shouldn't be used at lib/src/dev_compiler_bootstrap.dart:23:36 • deprecated_member_use
  hint • 'JSON' is deprecated and shouldn't be used at lib/src/dev_compiler_builder.dart:42:9 • deprecated_member_use
Analyzing node_io...
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/file.dart:133:64 • deprecated_member_use
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/file.dart:152:56 • deprecated_member_use
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/file.dart:158:52 • deprecated_member_use
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/file.dart:164:51 • deprecated_member_use
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/file.dart:170:47 • deprecated_member_use
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/file.dart:228:26 • deprecated_member_use
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/file.dart:237:26 • deprecated_member_use
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/file.dart:455:27 • deprecated_member_use
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/file.dart:461:59 • deprecated_member_use
  hint • Setter doesn't override an inherited setter at lib/src/internet_address.dart:32:7 • override_on_non_overriding_setter
  hint • 'UTF8' is deprecated and shouldn't be used at lib/src/streams.dart:171:57 • deprecated_member_use
  hint • 'UTF8' is deprecated and shouldn't be used at test/http_server_test.dart:20:41 • deprecated_member_use
  hint • 'JSON' is deprecated and shouldn't be used at test/http_server_test.dart:25:24 • deprecated_member_use
  hint • 'JSON' is deprecated and shouldn't be used at test/http_server_test.dart:26:34 • deprecated_member_use
Analyzing node_http...
  hint • 'UTF8' is deprecated and shouldn't be used at test/node_http_test.dart:20:41 • deprecated_member_use

Basically:

  • JSON to json
  • UTF8 to utf8
  • Fix setter override

HttpResponse.redirect() throws an exception

I am getting an exception when calling a redirect from a cloud function.

Invalid argument(s): object must be a Map or Iterable at Object.b (/srv/build/node/index.dart.js:1409:3) ...

Not sure if I am missing anything here. This is a short test version:

functions['redirectTest'] = FirebaseFunctions.https.onRequest( (ExpressHttpRequest rq) => rq.response.redirect(Uri.parse('https://www.bbc.co.uk')));

Bump build_config from ^0.2.5 to ^0.3.0

First thanks for this great project!

Seems that build_node_compilers doesn't play well with newest build_runner.

Using functions interop with:

  build_runner: ^0.8.10
  build_node_compilers: ^0.1.4

Gives error:

Because build_node_compilers >=0.1.2 depends on build_config ^0.2.5 and build_runner >=0.8.10 depends on build_config ^0.3.0, build_node_compilers >=0.1.2 is incompatible with build_runner >=0.8.10.
So, because functions depends on both build_runner ^0.8.10 and build_node_compilers ^0.1.4, version solving failed.
pub get failed (1)

Feature Request (or, How-to?): followRedirect HTTP 3xx Behaviour

Not sure how/where to enable this for node_http requests, but I would like to recursively follow HTTP responses with response code 3xx. In the node request module it is called "followRedirect" and/or "followAllRedirects". Hopefully it is already possible and just harder to find the config options (but I am also curious where to look to find out whether features like this are already supported)

calling headers.add gives a TypeError

I'm not sure if this is the right repo. I'm using Dart with Cloud Functions.

When I call headers.add on a response object I get the following error. Calling headers.set is working.
Since I haven't called headers.set prior to headers.add I assume that headers are not initialized here.

TypeError: receiver.getHeaders is not a function
    at UnknownJavaScriptObject.getHeaders$0 (/user_code/build/dart/index.dart.js:823:25)
    at J.getHeaders$0$x (/user_code/build/dart/index.dart.js:9526:41)
    at ResponseHttpHeaders.get$nativeHeaders (/user_code/build/dart/index.dart.js:8694:18)
    at ResponseHttpHeaders.$index (/user_code/build/dart/index.dart.js:8715:22)
    at ResponseHttpHeaders.add$2 (/user_code/build/dart/index.dart.js:8737:47)
    at /user_code/build/dart/index.dart.js:8975:25

Build failed on 2.8 dev due to new HttpHeaders.set method argument

I don't know if you have CI running on dev. The projects I have failed to compile on dev (2.8.0-dev.10)

00:02 +0: [Node.js] compiling test/context_node_test.dart                                                                                                                                              
../../../../.pub-cache/hosted/pub.dartlang.org/node_io-1.0.1+2/lib/src/http_headers.dart:314:8:
Error: The method 'HttpHeaders.set' has fewer named arguments than those of overridden method 'HttpHeaders.set'.
  void set(String name, Object value) {

Example here: https://travis-ci.org/tekartik/platform.dart/builds/653803172

There is a new argument preserveHeaderCase for HttpHeaders.set
https://api.dart.dev/dev/2.8.0-dev.10.0/dart-io/HttpHeaders/set.html
that your class should add.

Build fails without "lib/**"

Build with build_node_compilers fails without "lib/**" under build sources, even if there is no directory named "lib".

Reproduction:

Make a new directory and put three files below.

# pubspec.yaml
name: reproduction
description: reproduction

environment:
  sdk: ">=2.0.0 <3.0.0"

dev_dependencies:
  build_runner: ^1.0.0
  build_node_compilers: ^0.2.0
# build.yaml
targets:
  $default:
    sources:
      - "example/**"
// example/hello_world.dart
void main() {
  print('Hello World!');
}

Now, run pub run build_runner build --output=build/ . It will fail.
Then, add - "lib/**" to your build sources and run build command again. It will pass.

Unable to build node_io example on Dart 2.5

We have a project that uses node_io that is no longer building after upgrading Dart to 2.5.

As a sanity check, I cloned the node-interop repo and attempted to build node_io. It's producing the same error. Here is the output:

➜  node_io git:(master) pub run build_runner build --output=build
[INFO] Generating build script completed, took 284ms
[INFO] Creating build script snapshot... completed, took 11.3s
[INFO] Building new asset graph completed, took 992ms
[INFO] Checking for unexpected pre-existing outputs. completed, took 5ms
[WARNING] build_node_compilers:entrypoint on example/node_io.dart:
Skipping compiling node_io|example/node_io.dart with dart2js because some of its
transitive libraries have sdk dependencies that not supported on this platform:

node_io|lib/src/directory.dart
node_io|lib/src/http_headers.dart
node_io|lib/src/network_interface.dart
node_io|lib/src/file.dart
node_io|lib/src/streams.dart
node_io|lib/node_io.dart
node_io|lib/src/internet_address.dart
node_io|lib/src/link.dart
node_io|lib/src/file_system_entity.dart
node_io|lib/src/http_server.dart

https://github.com/dart-lang/build/blob/master/docs/faq.md#how-can-i-resolve-skipped-compiling-warnings

[INFO] Running build completed, took 3.2s
[INFO] Caching finalized dependency graph completed, took 108ms
[INFO] Creating merged output dir `build` completed, took 648ms
[INFO] Writing asset manifest completed, took 4ms
[INFO] Succeeded after 4.0s with 1215 outputs (4028 actions)

It appears to be skipping any file that imports dart:io.

The issue seems to be with build_node_compilers 0.2.2. If I pin it at 0.2.1 it builds successfully.

`pub run test -p node` broken on stable (2.8.4)

$ pub run test -p node test/http_memory_test.dart
Precompiling executable...
Failed to precompile test:test:
../../../../../../../.pub-cache/hosted/pub.dartlang.org/test_core-0.3.7/lib/test_core.dart:69:5: Error: 'unawaited' is imported from both 'package:meta/meta.dart' and 'package:test_api/src/utils.dart'.
    unawaited(Future.error('Dummy exception to set exit code.'));

Currently the solution is to add a dependency on meta lower than the latest one

meta: '<1.2.0'

Related issues (solved):

process.stdout/.stderr/.stdin types are wrong

The types for Process.stdout and Process.stderr are both listed as TTYWriteStream, and the type for Process.stdin is TTYReadStream. This isn't accurate: according to the Node docs, the only consistent guarantees are that stdout and stderr are Writeables and that stdin is a Readable. In practice, they're only TTY*Streams if a terminal is attached.

Building with dart2js ignores pubspec.yaml transformers options

pubspec.yaml:
transformers:
- $dart2js:
commandLineOptions: [--use-old-frontend]

Running the build command:
pub run build_runner build --define="build_node_compilers|entrypoint=compiler=dart2js" --output=build/

It ignores the commandLineOptions for dart2js. As a result all dart2js builds are failing in Dart SDK ^2.0.0-dev.37.0, at least until this Dart SDK bug is resolved: dart-lang/sdk#32547

Bump http to 0.12

Hello! Thanks for all the excellent work on node and firebase interop for Dart, it's a lifesaver! Can the http dep in node_http be bumped from 0.11.3 to a more modern version (currently http 0.12.0+1)? 0.11.3 is from 2015 and clashes with newer libraries. Thanks!

Stable node_io release?

Are there plans to release a stable version of node_io soon? I'd like to use it, but I'm uncomfortable relying on a dev version.

NodeClient fails to parse headers on response if a JSArray is included

final headers = new Map<String, String>.from(dartify(response.headers));

This line in node_http.dart throws a TypeError if the headers include a JSArray. The .from() call can't turn the JSArray into a basic type, so it complains that it can't turn it into a String:

TypeError: Instance of 'JSArray': type 'JSArray' is not a subtype of type 'String'
at wrapException (/user_code/build/node/index.dart.js:4440:17)
at assertSubtypeOfRuntimeType (/user_code/build/node/index.dart.js:5315:17)
at JsLinkedHashMap.$indexSet (/user_code/build/node/index.dart.js:6288:11)
at LinkedHashMap_LinkedHashMap$from_closure.call$2 (/user_code/build/node/index.dart.js:10190:21)
at JsLinkedHashMap.forEach$1 (/user_code/build/node/index.dart.js:6370:18)
at J.forEach$1$ax (/user_code/build/node/index.dart.js:43865:42)
at LinkedHashMap_LinkedHashMap$from (/user_code/build/node/index.dart.js:9571:9)
at NodeClientHeadersFix_send_handleResponse.dart.NodeClientHeadersFix_send_handleResponse.call$1 (/user_code/build/node/index.dart.js:43042:21)
at Primitives_applyFunctionWithPositionalArguments (/user_code/build/node/index.dart.js:4367:28)
at Function_apply (/user_code/build/node/index.dart.js:12105:14)

Not sure if this is a fault in javascript parsing the headers, dartify() not running recursively, or just an unconsidered use case.

My solution, which eliminates the .from() call (but likely introduces new problems):

Map headersTemp = dartify(response.headers);
Map headers = new Map<String, String>();
for (var key in headersTemp.keys){
  headers[key.toString()] = headersTemp[key].toString();
}

Unsupported operation: Platform._version in node_http post

When doing a http.post I get the following error:

Unsupported operation: Platform._version

http.get works fine. I will try to do a minimal use case but based on my tests it happens every time.

For context, this is after running dart2js and is being executed within the context of a firebase function. I also get the same error when I just try to use the dart/http package (as opposed to node_http) as well. Not sure if it is related to dart2js.

Package's lib directory is unavailable unless explicitly added to sources

The example configuration in the readme (without test and example)

targets:
  $default:
    sources:
      - "node/**"

fails with

$ pub run build_runner build --output node:build
[INFO] Generating build script completed, took 598ms
[INFO] Building new asset graph completed, took 617ms
[INFO] Checking for unexpected pre-existing outputs. completed, took 4ms
[SEVERE] build_node_compilers|entrypoint on node/foo.dart:

Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).

Please check the following imports:

`import 'package:foo/foo.dart';` from foo|node/foo.dart at 1:1

[INFO] Running build completed, took 2.6s
[INFO] Caching finalized dependency graph completed, took 94ms
[SEVERE] Failed after 2.7s

Changing build.yaml to

targets:
  $default:
    sources:
      - "lib/**"
      - "node/**"

helps:

[INFO] Generating build script completed, took 578ms
[WARNING] Throwing away cached asset graph because the build phases have changed. This most commonly would happen as a result of adding a new dependency or updating your dependencies.
[INFO] Cleaning up outputs from previous builds. completed, took 11ms
[INFO] Reading cached asset graph completed, took 252ms
[INFO] Building new asset graph completed, took 562ms
[INFO] Checking for unexpected pre-existing outputs. completed, took 4ms
[INFO] Running build completed, took 3.4s
[INFO] Caching finalized dependency graph completed, took 84ms
[INFO] Creating merged output dir `build` completed, took 9.1s
[INFO] Writing asset manifest completed, took 14ms
[INFO] Succeeded after 12.5s with 15 outputs (16 actions)

This is reproducible with both compilers.

Handle node build in sub directories with ddc (missing packages link)

Thanks a lot for your work. I have a small issue where if I create a subdirectory (in example), the resulting dart.js don't work in build (bad path to packages or missing packages link. I don't know if it is on purpose or not.

Le me explain the step to reproduce it in this repo

If i do

pub run build_runner build --output build/
node build/example/console_example.dart.js

everything works fine.

Now let's create a sub directory in example and copy console_example.dart (we have a file build/example/sub/console_example.dart'

If i do

pub run build_runner build --output build/

dart.js and node.ddc.js are compiled fine. however

node build/example/sub/console_example.dart.js

throws

annot find module '/media/files/local/dev/external/git/github.com/pulyaevskiy/node-interop/node_interop/build/example/sub/packages/$sdk/dev_compiler/common/dart_sdk'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    at Module.require (internal/modules/cjs/loader.js:598:17)

Indeed the build/example/sub/packages link does not exist.

To note that if I build with dart2js

pub run build_runner build --output build/ --define="build_node_compilers|entrypoint=compiler=dart2js"
node build/example/sub/console_example.dart.js

it works fine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.