Giter Site home page Giter Site logo

workiva / dart_to_js_script_rewriter Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 20.0 51 KB

A pub transformer that Rewrites Dart script tags to JavaScript script tags, eliminating 404s and speeding up initial loads. Use when building for deployment.

License: BSD 3-Clause "New" or "Revised" License

CSS 3.90% Dart 85.23% HTML 9.69% Dockerfile 1.19%

dart_to_js_script_rewriter's People

Contributors

azenla avatar bcko avatar charliekump-wf avatar claudiodangelis avatar devoncarew avatar domesticmouse avatar evanweible-wf avatar greglittlefield-wf avatar jayudey-wf avatar josephswanson-wf avatar kasperpeulen avatar kevmoo avatar maxwellpeterson-wf avatar rmconsole3-wf avatar robbecker-wf avatar sethladd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dart_to_js_script_rewriter's Issues

Query strings in script urls aren't handled well

.js is added to the end of script URLs when they are rewritten, even when the URLs contain query strings.

For example:

Input:

<script type="application/dart" src="entrypoint.dart?cache_busting_query"></script>

Expected output:

<script src="entrypoint.dart.js?cache_busting_query"></script>

Actual output:

<script src="entrypoint.dart?cache_busting_query.js"></script>

Conflicts with Angular Transformer

Hard to identify if this is a dart to js script rewriter or an angular transformer problem but I thought I would start here.

If I have the dart_to_js_script_rewriter transformer first and then the angular transformer, the release pub build version causes errors at run time. The error is always that a method is missing in an angular controller, but it only happens when this transformer is first.

I have it happening in 2 fairly simple projects.

Support swapping dev and deploy React scripts.

As a React developer,
I want a tool to automatically switch between prod and dev React scripts,
So that I can maintain error messages locally and deploy minified code seamlessly.
This seems like it'd be an apt place to put this functionality since it performs identical functionality for Dart scripts and I'm not sure many people are using Dart without React.

Acceptance criteria:

  1. <script src="packages/react/react_with_react_dom_prod.js"></script> Used for deploys.
  2. <script src="packages/react/react.js"></script> <script src="packages/react/react_dom.js"></script> Used for development.

Feature Request: autoload webcomponents.js and dart_support.js for non-chrome browsers

test.dart.js could detect whether the browser supports the ShadowDom and if not, include the following scripts:

<script async src="packages/web_components/webcomponents.min.js"></script>
<script async src="packages/web_components/dart_support.js"></script>

The scripts would then be skipped in browsers supporting ShadowDom, which should speed up load time.

Let me know if this sounds like a reasonable idea.

" zero or multiple dart scripts" error

Even though I have reference to a single dart script, I get the following error on "release" build.

[Error from ScriptCompactor on Project|web/index.html]:
Found either zero or multiple dart scripts in the entry point `web/index.html`. Exactly one was expected.

I do have references to two other JavaScript scripts in the same index.html.

I am not sure if I am doing something wrong, or this is a bug.

transformer also transforms html files in lib

The transformer also transforms html files in lib, this can give problems together with angular2 for example. It would be better I think if this would only transform files in web, and also only change the html if there is a match.

it now adds html/body tags to angular templates for example:

corner case behavior when trying to debug javascript

I ran into a corner case behavior when trying to debug the compiled javascript app. It was optimized - which is super hard to debug. So I built the app with --mode=debug. It no longer started up, because the index.html file was not re-written by this transformer.

Note that I am not using the browser packages dart.js file; I use this transformer instead.

Not sure what a fix would be -

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.