Discussion:
[dart-misc] How can I output code that can be loaded as a node module?
Danny Tuppeny
2016-07-29 12:10:32 UTC
Permalink
Is there any way (today, either using dart2js or dev compiler) to write
Dart that would effectively output this?


var vscode = require('vscode');

function activate(context) {
}

function deactivate() {
}

exports.activate = activate;
exports.deactivate = deactivate;

The "vscode" variable can be typed as Dynamic, but I need to get a
reference to it and I need to set those two functions against the exports
object.

I've been trying for the last few hours without much success (the output of
dart2js doesn't make it easier either, and I can't even get the devcompiler
to output anything other than a fairly empty stub function).

Here's what I've got so far (I don't know if this is right; like I say,
hard to read dart2js output) but I need the output to be loadable as a node
js module.

@JS("extension")
library extension;

import "dart:js";
import "package:js/js.dart";

main() {
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}

activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!');
//var disposable =
vscode.commands.registerCommand('extension.sayHello', function () {
// vscode.window.showInformationMessage('Hello World!');
//});
//context.subscriptions.push(disposable);
}

deactivate() {
}
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Danny Tuppeny
2016-07-29 12:58:47 UTC
Permalink
I managed to get further with this code:

@JS()
library extension;

import "dart:js";
import "package:js/js.dart";

dynamic vscode;

@JS()
external require(String module);

main() {
vscode = require('vscode');

print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}

activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!');
var disposable = vscode.commands.registerCommand('extension.sayHello',
() {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}

deactivate() {
}

This gave an error (self is undefined or something)... Managed to get
slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
to my dart2js output. Now I'm getting this:

Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property 'set$activate' of
undefined
at dart.main (m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9

So I'm guessing something is up with context['exports'] though I'm not sure
how to fix it. I tried this:

@JS()
external dynamic exports;

However that seems to crash the analyzer (I guess it's a bug to crash in
this way, I'll file at GH):

PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
Unhandled exception:
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\TestStuff\dartvs
-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for source M
:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform (package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2016-07-29 16:17:56 UTC
Permalink
+jmesserly

I don't know the details very well, but, yes, you can tell dev_compiler to
output a node module and then use JS interop to talk to native node
libraries. I think the command line flag to pass to dev_compiler is
--modules=node
<https://github.com/dart-lang/dev_compiler/blob/d39946fd7af11d02a8831dbd7a2b776c69099ff6/lib/src/compiler/compiler.dart#L248>
.

Cheers!

– bob
Post by Danny Tuppeny
@JS()
library extension;
import "dart:js";
import "package:js/js.dart";
dynamic vscode;
@JS()
external require(String module);
main() {
vscode = require('vscode');
print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}
activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!');
var disposable = vscode.commands.registerCommand('extension.sayHello',
() {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
deactivate() {
}
This gave an error (self is undefined or something)... Managed to get
slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property 'set$activate' of
undefined
at dart.main (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9
So I'm guessing something is up with context['exports'] though I'm not
@JS()
external dynamic exports;
However that seems to crash the analyzer (I guess it's a bug to crash in
PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\TestStuff\
dartvs-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for source
M:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform (package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Samuel Rawlins' via Dart Misc
2016-07-29 16:21:27 UTC
Permalink
Also see https://github.com/dart-lang/dev_compiler/issues/485 with
instructions.

On Fri, Jul 29, 2016 at 9:17 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
+jmesserly
I don't know the details very well, but, yes, you can tell dev_compiler to
output a node module and then use JS interop to talk to native node
libraries. I think the command line flag to pass to dev_compiler is
--modules=node
<https://github.com/dart-lang/dev_compiler/blob/d39946fd7af11d02a8831dbd7a2b776c69099ff6/lib/src/compiler/compiler.dart#L248>
.
Cheers!
– bob
Post by Danny Tuppeny
@JS()
library extension;
import "dart:js";
import "package:js/js.dart";
dynamic vscode;
@JS()
external require(String module);
main() {
vscode = require('vscode');
print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}
activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!'
);
var disposable = vscode.commands.registerCommand('extension.sayHello'
, () {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
deactivate() {
}
This gave an error (self is undefined or something)... Managed to get
slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property 'set$activate'
of undefined
at dart.main (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9
So I'm guessing something is up with context['exports'] though I'm not
@JS()
external dynamic exports;
However that seems to crash the analyzer (I guess it's a bug to crash in
PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\TestStuff\
dartvs-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for
source M:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform (package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Danny Tuppeny
2016-07-29 16:31:27 UTC
Permalink
The first line of generated code is:

dart_library.library(...

dart_library is undefined... am I supposed to have a dev_compiler build of
the SDK (or the bits I use) in my output? I tried passing --dart-sdk and a
path but that didn't change anything (though I suspect it already knew
where the SDK was since it's running from it!).
Post by 'Samuel Rawlins' via Dart Misc
Also see https://github.com/dart-lang/dev_compiler/issues/485 with
instructions.
On Fri, Jul 29, 2016 at 9:17 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
+jmesserly
I don't know the details very well, but, yes, you can tell dev_compiler
to output a node module and then use JS interop to talk to native node
libraries. I think the command line flag to pass to dev_compiler is
--modules=node
<https://github.com/dart-lang/dev_compiler/blob/d39946fd7af11d02a8831dbd7a2b776c69099ff6/lib/src/compiler/compiler.dart#L248>
.
Cheers!
– bob
Post by Danny Tuppeny
@JS()
library extension;
import "dart:js";
import "package:js/js.dart";
dynamic vscode;
@JS()
external require(String module);
main() {
vscode = require('vscode');
print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}
activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!'
);
var disposable = vscode.commands.registerCommand(
'extension.sayHello', () {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
deactivate() {
}
This gave an error (self is undefined or something)... Managed to get
slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property 'set$activate'
of undefined
at dart.main (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9
So I'm guessing something is up with context['exports'] though I'm not
@JS()
external dynamic exports;
However that seems to crash the analyzer (I guess it's a bug to crash in
PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\TestStuff\
dartvs-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for
source M:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform
(package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'John Messerly' via Dart Misc
2016-07-29 16:46:46 UTC
Permalink
Dart SDK is at
https://github.com/dart-lang/dev_compiler/blob/master/lib/runtime/dart_sdk.js

dart_library is a little fake module system for the browser (because
browsers don't support ES6 module loading yet). You shouldn't need it if
you're compiling with ES6 or node modules. But if you did want it, it's in
dart_library.js right next to the SDK file I linked above.
Post by Danny Tuppeny
dart_library.library(...
dart_library is undefined... am I supposed to have a dev_compiler build of
the SDK (or the bits I use) in my output? I tried passing --dart-sdk and a
path but that didn't change anything (though I suspect it already knew
where the SDK was since it's running from it!).
Post by 'Samuel Rawlins' via Dart Misc
Also see https://github.com/dart-lang/dev_compiler/issues/485 with
instructions.
On Fri, Jul 29, 2016 at 9:17 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
+jmesserly
I don't know the details very well, but, yes, you can tell dev_compiler
to output a node module and then use JS interop to talk to native node
libraries. I think the command line flag to pass to dev_compiler is
--modules=node
<https://github.com/dart-lang/dev_compiler/blob/d39946fd7af11d02a8831dbd7a2b776c69099ff6/lib/src/compiler/compiler.dart#L248>
.
Cheers!
– bob
Post by Danny Tuppeny
@JS()
library extension;
import "dart:js";
import "package:js/js.dart";
dynamic vscode;
@JS()
external require(String module);
main() {
vscode = require('vscode');
print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}
activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!');
var disposable = vscode.commands.registerCommand(
'extension.sayHello', () {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
deactivate() {
}
This gave an error (self is undefined or something)... Managed to get
slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property 'set$activate'
of undefined
at dart.main (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9
So I'm guessing something is up with context['exports'] though I'm not
@JS()
external dynamic exports;
However that seems to crash the analyzer (I guess it's a bug to crash
PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\TestStuff\
dartvs-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for
source M:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform
(package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Vijay Menon' via Dart Misc
2016-07-29 16:58:32 UTC
Permalink
Danny,

If you follow the steps here (3rd comment):

https://github.com/dart-lang/dev_compiler/issues/485

You should not see this.

Vijay

On Fri, Jul 29, 2016 at 9:46 AM, 'John Messerly' via Dart Misc <
Post by 'John Messerly' via Dart Misc
Dart SDK is at
https://github.com/dart-lang/dev_compiler/blob/master/lib/runtime/dart_sdk.js
dart_library is a little fake module system for the browser (because
browsers don't support ES6 module loading yet). You shouldn't need it if
you're compiling with ES6 or node modules. But if you did want it, it's in
dart_library.js right next to the SDK file I linked above.
Post by Danny Tuppeny
dart_library.library(...
dart_library is undefined... am I supposed to have a dev_compiler build
of the SDK (or the bits I use) in my output? I tried passing --dart-sdk and
a path but that didn't change anything (though I suspect it already knew
where the SDK was since it's running from it!).
Post by 'Samuel Rawlins' via Dart Misc
Also see https://github.com/dart-lang/dev_compiler/issues/485 with
instructions.
On Fri, Jul 29, 2016 at 9:17 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
+jmesserly
I don't know the details very well, but, yes, you can tell dev_compiler
to output a node module and then use JS interop to talk to native node
libraries. I think the command line flag to pass to dev_compiler is
--modules=node
<https://github.com/dart-lang/dev_compiler/blob/d39946fd7af11d02a8831dbd7a2b776c69099ff6/lib/src/compiler/compiler.dart#L248>
.
Cheers!
– bob
Post by Danny Tuppeny
@JS()
library extension;
import "dart:js";
import "package:js/js.dart";
dynamic vscode;
@JS()
external require(String module);
main() {
vscode = require('vscode');
print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}
activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!');
var disposable = vscode.commands.registerCommand(
'extension.sayHello', () {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
deactivate() {
}
This gave an error (self is undefined or something)... Managed to get
slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property
'set$activate' of undefined
at dart.main (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9
So I'm guessing something is up with context['exports'] though I'm not
@JS()
external dynamic exports;
However that seems to crash the analyzer (I guess it's a bug to crash
PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\TestStuff\
dartvs-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for
source M:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform
(package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Danny Tuppeny
2016-07-29 17:12:56 UTC
Permalink
Oops, I had somehow lost "--modules node" from my command when I was
looking for options to include the SDK. Adding that in removes dart_library
:-)

The instructions you mentioned look like it'll let me build a node version
of the SDK (since the version John linked also requires dart_library) but
it has a path to a /gen/ folder (a patched SDK?) in the args that I don't
see in the repo. Are there any instructions on this; or can I just pass the
release 1.18 SDK? (or would it be simpler to just try and use dart_library
despite being in node?).

Thanks!
Post by 'Vijay Menon' via Dart Misc
Danny,
https://github.com/dart-lang/dev_compiler/issues/485
You should not see this.
Vijay
On Fri, Jul 29, 2016 at 9:46 AM, 'John Messerly' via Dart Misc <
Post by 'John Messerly' via Dart Misc
Dart SDK is at
https://github.com/dart-lang/dev_compiler/blob/master/lib/runtime/dart_sdk.js
dart_library is a little fake module system for the browser (because
browsers don't support ES6 module loading yet). You shouldn't need it if
you're compiling with ES6 or node modules. But if you did want it, it's in
dart_library.js right next to the SDK file I linked above.
Post by Danny Tuppeny
dart_library.library(...
dart_library is undefined... am I supposed to have a dev_compiler build
of the SDK (or the bits I use) in my output? I tried passing --dart-sdk and
a path but that didn't change anything (though I suspect it already knew
where the SDK was since it's running from it!).
Post by 'Samuel Rawlins' via Dart Misc
Also see https://github.com/dart-lang/dev_compiler/issues/485 with
instructions.
On Fri, Jul 29, 2016 at 9:17 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
+jmesserly
I don't know the details very well, but, yes, you can tell
dev_compiler to output a node module and then use JS interop to talk to
native node libraries. I think the command line flag to pass to
dev_compiler is --modules=node
<https://github.com/dart-lang/dev_compiler/blob/d39946fd7af11d02a8831dbd7a2b776c69099ff6/lib/src/compiler/compiler.dart#L248>
.
Cheers!
– bob
Post by Danny Tuppeny
@JS()
library extension;
import "dart:js";
import "package:js/js.dart";
dynamic vscode;
@JS()
external require(String module);
main() {
vscode = require('vscode');
print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}
activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!');
var disposable = vscode.commands.registerCommand(
'extension.sayHello', () {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
deactivate() {
}
This gave an error (self is undefined or something)... Managed to get
slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read
property 'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read
property 'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property
'set$activate' of undefined
at dart.main (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9
So I'm guessing something is up with context['exports'] though I'm
@JS()
external dynamic exports;
However that seems to crash the analyzer (I guess it's a bug to crash
PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\TestStuff
\dartvs-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for
source M:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform
(package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it,
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Vijay Menon' via Dart Misc
2016-07-29 17:17:33 UTC
Permalink
./tool/build_sdk.sh
first in a ddc checkout to populate that gen folder.
Oops, I had somehow lost "--modules node" from my command when I was
looking for options to include the SDK. Adding that in removes dart_library
:-)
The instructions you mentioned look like it'll let me build a node version
of the SDK (since the version John linked also requires dart_library) but
it has a path to a /gen/ folder (a patched SDK?) in the args that I don't
see in the repo. Are there any instructions on this; or can I just pass the
release 1.18 SDK? (or would it be simpler to just try and use dart_library
despite being in node?).
Thanks!
Post by 'Vijay Menon' via Dart Misc
Danny,
https://github.com/dart-lang/dev_compiler/issues/485
You should not see this.
Vijay
On Fri, Jul 29, 2016 at 9:46 AM, 'John Messerly' via Dart Misc <
Post by 'John Messerly' via Dart Misc
Dart SDK is at
https://github.com/dart-lang/dev_compiler/blob/master/lib/runtime/dart_sdk.js
dart_library is a little fake module system for the browser (because
browsers don't support ES6 module loading yet). You shouldn't need it if
you're compiling with ES6 or node modules. But if you did want it, it's in
dart_library.js right next to the SDK file I linked above.
Post by Danny Tuppeny
dart_library.library(...
dart_library is undefined... am I supposed to have a dev_compiler build
of the SDK (or the bits I use) in my output? I tried passing --dart-sdk and
a path but that didn't change anything (though I suspect it already knew
where the SDK was since it's running from it!).
Post by 'Samuel Rawlins' via Dart Misc
Also see https://github.com/dart-lang/dev_compiler/issues/485 with
instructions.
On Fri, Jul 29, 2016 at 9:17 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
+jmesserly
I don't know the details very well, but, yes, you can tell
dev_compiler to output a node module and then use JS interop to talk to
native node libraries. I think the command line flag to pass to
dev_compiler is --modules=node
<https://github.com/dart-lang/dev_compiler/blob/d39946fd7af11d02a8831dbd7a2b776c69099ff6/lib/src/compiler/compiler.dart#L248>
.
Cheers!
– bob
Post by Danny Tuppeny
@JS()
library extension;
import "dart:js";
import "package:js/js.dart";
dynamic vscode;
@JS()
external require(String module);
main() {
vscode = require('vscode');
print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}
activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!');
var disposable = vscode.commands.registerCommand(
'extension.sayHello', () {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
deactivate() {
}
This gave an error (self is undefined or something)... Managed to
get slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read
property 'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read
property 'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property
'set$activate' of undefined
at dart.main (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9
So I'm guessing something is up with context['exports'] though I'm
@JS()
external dynamic exports;
However that seems to crash the analyzer (I guess it's a bug to
PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\
TestStuff\dartvs-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for
source M:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform
(package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it,
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it,
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Danny Tuppeny
2016-07-29 17:18:25 UTC
Permalink
Actually, it turned out to be trivial to just tweak dart_sdk (I found
the difference
here
<https://github.com/dart-lang/dev_compiler/issues/597#issuecomment-230016862>
).

Slowly getting there!
Post by Danny Tuppeny
Oops, I had somehow lost "--modules node" from my command when I was
looking for options to include the SDK. Adding that in removes dart_library
:-)
The instructions you mentioned look like it'll let me build a node version
of the SDK (since the version John linked also requires dart_library) but
it has a path to a /gen/ folder (a patched SDK?) in the args that I don't
see in the repo. Are there any instructions on this; or can I just pass the
release 1.18 SDK? (or would it be simpler to just try and use dart_library
despite being in node?).
Thanks!
Post by 'Vijay Menon' via Dart Misc
Danny,
https://github.com/dart-lang/dev_compiler/issues/485
You should not see this.
Vijay
On Fri, Jul 29, 2016 at 9:46 AM, 'John Messerly' via Dart Misc <
Post by 'John Messerly' via Dart Misc
Dart SDK is at
https://github.com/dart-lang/dev_compiler/blob/master/lib/runtime/dart_sdk.js
dart_library is a little fake module system for the browser (because
browsers don't support ES6 module loading yet). You shouldn't need it if
you're compiling with ES6 or node modules. But if you did want it, it's in
dart_library.js right next to the SDK file I linked above.
Post by Danny Tuppeny
dart_library.library(...
dart_library is undefined... am I supposed to have a dev_compiler build
of the SDK (or the bits I use) in my output? I tried passing --dart-sdk and
a path but that didn't change anything (though I suspect it already knew
where the SDK was since it's running from it!).
Post by 'Samuel Rawlins' via Dart Misc
Also see https://github.com/dart-lang/dev_compiler/issues/485 with
instructions.
On Fri, Jul 29, 2016 at 9:17 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
+jmesserly
I don't know the details very well, but, yes, you can tell
dev_compiler to output a node module and then use JS interop to talk to
native node libraries. I think the command line flag to pass to
dev_compiler is --modules=node
<https://github.com/dart-lang/dev_compiler/blob/d39946fd7af11d02a8831dbd7a2b776c69099ff6/lib/src/compiler/compiler.dart#L248>
.
Cheers!
– bob
Post by Danny Tuppeny
@JS()
library extension;
import "dart:js";
import "package:js/js.dart";
dynamic vscode;
@JS()
external require(String module);
main() {
vscode = require('vscode');
print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}
activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!');
var disposable = vscode.commands.registerCommand(
'extension.sayHello', () {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
deactivate() {
}
This gave an error (self is undefined or something)... Managed to
get slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read
property 'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read
property 'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property
'set$activate' of undefined
at dart.main (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9
So I'm guessing something is up with context['exports'] though I'm
@JS()
external dynamic exports;
However that seems to crash the analyzer (I guess it's a bug to
PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\
TestStuff\dartvs-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for
source M:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform
(package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it,
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it,
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Danny Tuppeny
2016-07-29 16:21:38 UTC
Permalink
I've actually been trying with the dev compiler for a little while after
posting this :)

I hit a differnt issue:

https://github.com/dart-lang/dev_compiler/issues/615

However that's more specific to what I need and John Messerly suggested a
small wrapper as a workaround. Giving it a go, though I really have no idea
how complete/stable the dev compiler is, so I don't know if going down this
route is a good path (I'm going to be relying on calling plain JS objects
heavily! ...)
Post by 'Bob Nystrom' via Dart Misc
+jmesserly
I don't know the details very well, but, yes, you can tell dev_compiler to
output a node module and then use JS interop to talk to native node
libraries. I think the command line flag to pass to dev_compiler is
--modules=node
<https://github.com/dart-lang/dev_compiler/blob/d39946fd7af11d02a8831dbd7a2b776c69099ff6/lib/src/compiler/compiler.dart#L248>
.
Cheers!
– bob
Post by Danny Tuppeny
@JS()
library extension;
import "dart:js";
import "package:js/js.dart";
dynamic vscode;
@JS()
external require(String module);
main() {
vscode = require('vscode');
print(context);
context['exports'].activate = activate;
context['exports'].deactivate = deactivate;
}
activate(dynamic context) {
print('Congratulations, your extension "dartvs-code" is now active!'
);
var disposable = vscode.commands.registerCommand('extension.sayHello'
, () {
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
deactivate() {
}
This gave an error (self is undefined or something)... Managed to get
slightly further by pre-pending the contents of the JS file in
the node_preamble package
<https://github.com/mbullington/node_preamble.dart/blob/master/lib/preamble.js>
Loading development extension at m:/Coding/TestStuff/dartvs-code
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined.
Activating extension `DanTup.dartvs-code` failed: Cannot read property
'set$activate' of undefined
Here is the error stack: TypeError: Cannot read property 'set$activate'
of undefined
at dart.main (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6130:34)
at _IsolateContext.dart._IsolateContext.eval$1 (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1342:25)
at dart.startRootIsolate (
m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:1054:23)
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6752:11
at m:\Coding\TestStuff\dartvs-code\dartvsjs\extension.js:6753:9
So I'm guessing something is up with context['exports'] though I'm not
@JS()
external dynamic exports;
However that seems to crash the analyzer (I guess it's a bug to crash in
PS M:\Coding\TestStuff\dartvs-code\dartvs> dartanalyzer . --strong
Analyzing [.]...
AnalysisException: Cannot compute DART_ERRORS for M:\Coding\TestStuff\
dartvs-code\dartvs\lib\extension.dart
Caused by Unexpected exception while performing VerifyUnitTask for
source M:\Coding\TestStuff\dartvs-code\dartvs\lib\extension.dart
#0 AnalysisTask._safelyPerform (package:analyzer/task/model.dart:350)
#1 AnalysisTask.perform (package:analyzer/task/model.dart:238)
#2 AnalysisDriver.performWorkItem
(package:analyzer/src/task/driver.dart:284)
#3 AnalysisDriver.computeResult
(package:analyzer/src/task/driver.dart:109)
#4 AnalysisContextImpl.computeResult
(package:analyzer/src/context/context.dart:703)
#5 AnalysisContextImpl.computeErrors
(package:analyzer/src/context/context.dart:651)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2016-07-29 17:38:38 UTC
Permalink
Giving it a go, though I really have no idea how complete/stable the dev
compiler is, so I don't know if going down this route is a good path (I'm
going to be relying on calling plain JS objects heavily! ...)
It might be a bit of a rocky road today, but I personally think it's a
great path to explore and it would be great to get some feedback on it.
Running Dart apps on node using dev_compiler and JS interop is a subject
close to my heart (but, alas, not close to my *schedule...*).

– bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Danny Tuppeny
2016-07-29 17:57:12 UTC
Permalink
Giving it a go, though I really have no idea how complete/stable the dev
compiler is, so I don't know if going down this route is a good path (I'm
going to be relying on calling plain JS objects heavily! ...)
It might be a bit of a rocky road today, but I personally think it's a
great path to explore and it would be great to get some feedback on it.
Running Dart apps on node using dev_compiler and JS interop is a subject
close to my heart (but, alas, not close to my *schedule...*).
Schedules, shmedules!

Do you know of anyone else is trying to do this (that maybe I can "borrow"
ideas from if I hit issues)?
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2016-07-29 20:30:34 UTC
Permalink
Post by Danny Tuppeny
Do you know of anyone else is trying to do this (that maybe I can "borrow"
ideas from if I hit issues)?
I don't offhand, sorry.

– bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
alberto.ags
2016-07-29 17:57:47 UTC
Permalink
now that clearly Dart focuses only to compile to js will be a first class
feature add a option to compile for node.js directly.



On Fri, Jul 29, 2016 at 7:38 PM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
Giving it a go, though I really have no idea how complete/stable the dev
compiler is, so I don't know if going down this route is a good path (I'm
going to be relying on calling plain JS objects heavily! ...)
It might be a bit of a rocky road today, but I personally think it's a
great path to explore and it would be great to get some feedback on it.
Running Dart apps on node using dev_compiler and JS interop is a subject
close to my heart (but, alas, not close to my *schedule...*).
– bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Continue reading on narkive:
Loading...