Coder Social home page Coder Social logo

Comments (5)

Rexios80 avatar Rexios80 commented on June 26, 2024

What if you do something like:

import 'stub.dart'
  if (dart.library.html) 'html_impl.dart'
  if (dart.library.js_interop) 'js_interop_impl.dart';

If the evaludation is short circuited, then the html implementation should be used on old web platforms and the js_interop implementation should be used on WASM.

from sdk.

AlexV525 avatar AlexV525 commented on June 26, 2024

What if you do something like:

import 'stub.dart'
  if (dart.library.html) 'html_impl.dart'
  if (dart.library.js_interop) 'js_interop_impl.dart';

If the evaludation is short circuited, then the html implementation should be used on old web platforms and the js_interop implementation should be used on WASM.

This could work if the condition is not running into any compile issues.

from sdk.

sigmundch avatar sigmundch commented on June 26, 2024

Potentially we could treat this as a duplicate of #55694?

cc @osa1

from sdk.

osa1 avatar osa1 commented on June 26, 2024

Potentially we could treat this as a duplicate of #55694?

Yes, I think this is a duplicate #55694.

from sdk.

sigmundch avatar sigmundch commented on June 26, 2024

I'll close this so we can track the idea of the new condition in the other issue.

I forgot to mention - the workaround suggested by @Rexios80 above is also what we recommend for distinguishing runtimes under the current available conditional import conditions.

dart:html is supported in JavaScript compilers (DDC and dart2js) and not Wasm, so dart.library.html can be used to distinguish between the various JS runtimes, similarly dart.library.js_interop helps distinguish wasm from the VM runtime.

In the past some people have used js and js_util, but it's likely those will not be supported in Wasm in the future, and as such, we normally recommend using .js_interop instead.

This could work if the condition is not running into any compile issues.

Can you clarify what's your concern? I'm not sure I follow

from sdk.

Related Issues (20)

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.