-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Js interop and local vars #25033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@Aetet would you share the API you're trying to work with? |
I build my code with webpack, which can understand CommonJS module. import from '../dart/build/web/main.dart.js' That's good. But I want export some vars from dart code. For example variable `a = 'Hello', import {a} from '../dart/build/web/main.dart.js' So webpack wrap compiled code of main.dart.js like this: (function(modules) {
// Operation over modules
})([
// a lot of js modules
// And here will be compiled dart module
function(module, exports, __webpack_require__) {
eval("(function(){compiled dart code})()");
]) So if dart code can operate with |
@Aetet I think I understand. Our focus w/ this first set of work is to enable consumption of JS APIs from within a Dart app. We want to be able to enable the creation of JS libraries from Dart, but that work will happen later. I think your request is along those lines... |
@jacob314 Is any update on this? |
merging into #25059 |
Currently js interop works fine with global vars, but what about local vars through closure? If it will support it, then it will has clear exports and require. Because in all module systems that's just
If in js interop we can access to local vars like:
require, exports, module
then we can make all require and exports clear to user like:Or we can add new annotation for require:
There's some problem with new annotation is what will be cwd ? Current directory with dart file or with compiled dart file.
So we can use js modules like request in dart and exporting code from dart without syntax change.
The text was updated successfully, but these errors were encountered: