How do I write a Dart web app that uses spawnUri and works with both Dartium and dart2js?

StackOverflow https://stackoverflow.com/questions/21226053

  •  30-09-2022
  •  | 
  •  

문제

I want to write a concurrent web app (using either raw Workers or isolates as workers). The Dart API for isolates is spawnUri, which takes a URI that points to a script.

In Dartium, that script is a .dart file. In Chrome/Firefox/etc that script is a .dart.js file.

I need to detect what runtime I'm in so I can configure the URI for spawnUri correctly. What is the best way to do this?

도움이 되었습니까?

해결책

SpawnUri automatically appends ".js" when compiled to JavaScript.

다른 팁

How about using transformers? Here is a document about how transformers work, some Google internal documentation. There's also some info about transformers on pub pages - assets and transformers. What you could do is use transformers to output "rewrite" your files a bit to use correct url.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top