(我在dart2js上工作失败了,所以我尝试使用dart dev编译器;但是我很乐意为dart2j做一个答案!)。
如果我有test.dart
:
void activate() {
print("activating...");
}
并运行dartdevc --modules node -o test.js test.dart
输出为:
(function() {
'use strict';
const dart_sdk = require('dart_sdk');
const core = dart_sdk.core;
const dart = dart_sdk.dart;
const dartx = dart_sdk.dartx;
const __test = Object.create(null);
let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [])))();
__test.activate = function() {
core.print("activating...");
};
dart.fn(__test.activate, VoidTovoid());
// Exports:
exports.__test = __test;
})();
这意味着我的功能导出为__test.activate
,但我需要的只是activate
。
我该如何控制? JS我的目标是等同于此:
exports.activate = function() { core.print("activating"); }
答案 0 :(得分:0)
这是isn't currently possible,但我用一个包装器解决了这个问题:
var extension = require('./dartvsjs/extension.js');
exports.activate = extension.__lib__extension.activate;
exports.deactivate = extension.__lib__extension.deactivate;