Discussion:
[dart-misc] The new build package looks awesome, but I'm really confused on how to actually use it...
Ryan Gonzalez
2017-12-08 17:59:58 UTC
Permalink
Okay, so I've been trying to learn how to use the new build package:

https://github.com/dart-lang/build

And it looks awesome! However, I'm having a hard time trying to figure out
how to use this from a practical standpoint.

Okay, so most Dart transformers do something like this:

- take input.dart
- do something with out
- output a new input.dart

Now, the build package has a requirement that builders can't overwrite
their inputs...which makes total sense. However, this is where things get
confusing.

Say I have index.html:


<head>
<title>something</title>
<script src="index.dart"></script> <!-- look here -->
<script src="packages/browser/dart.js"></script>
</head>

Now, I want to run some transformation on index.dart as part of the build
process. However, since I can't replace index.dart, I have to write it out
to another file ...let's say it's index.processed.dart. Now, the HTML file
needs to be rewritten to reference the new file...but files can't be
overwritten. So in the end, I'd have to change index.html to something
else.

Of course, this isn't really that practical. I'm pretty sure there has to
be some way of doing this simple workflow, but I just can't figure out how.
:/
--
Ryan (ライアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2017-12-08 20:44:43 UTC
Permalink
+Jake and Nate, who work on this...
Post by Ryan Gonzalez
https://github.com/dart-lang/build
And it looks awesome! However, I'm having a hard time trying to figure out
how to use this from a practical standpoint.
- take input.dart
- do something with out
- output a new input.dart
Now, the build package has a requirement that builders can't overwrite
their inputs...which makes total sense. However, this is where things get
confusing.
<head>
<title>something</title>
<script src="index.dart"></script> <!-- look here -->
<script src="packages/browser/dart.js"></script>
</head>
Now, I want to run some transformation on index.dart as part of the build
process. However, since I can't replace index.dart, I have to write it out
to another file ...let's say it's index.processed.dart. Now, the HTML file
needs to be rewritten to reference the new file...but files can't be
overwritten. So in the end, I'd have to change index.html to something else.
Of course, this isn't really that practical. I'm pretty sure there has to
be some way of doing this simple workflow, but I just can't figure out how.
:/
Yeah, that is a challenge. For what it's worth, this use case is exactly
why the old barback build system *does* let you overwrite files, even
though supporting that causes a lot of other complexity.

I'm not sure what the idiomatic solution for this is with the new build
system. I think what you'd probably do is in your index.html file,
reference the file that *will* be built — the output file at its new
location — and not the original input file.

Cheers!

– bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Nate Bosch' via Dart Misc
2017-12-08 20:57:49 UTC
Permalink
This challenge definitely has come up before and it usually fits into a
pattern:

User has written some code and their entrypoint (index.dart, index.html,
etc) refers only to code they've written.
Builder wants to generate new code but without being referenced it can't be
used.

Angular, package:initialize, and dart_to_js_script_rewriter all fit this
pattern. For the most part, these patterns show up when there are two ways
of executing the code (mirrors vs no mirrors, dartium running dart vs
chrome running js) and in most cases the direction we're moving is to have
only 1 way for executing the code.

Most of the time what this means is that the user needs to write something
a bit different, and reference files they didn't write. In your example
we'd ask the user to write their html with <script
src="index.processed.dart">

We've discussed finding some way to model this with package:build but so
far we have not found anything satisfying, so we're sticking doing the
changes manually for now.
Post by 'Bob Nystrom' via Dart Misc
+Jake and Nate, who work on this...
Post by Ryan Gonzalez
https://github.com/dart-lang/build
And it looks awesome! However, I'm having a hard time trying to figure
out how to use this from a practical standpoint.
- take input.dart
- do something with out
- output a new input.dart
Now, the build package has a requirement that builders can't overwrite
their inputs...which makes total sense. However, this is where things get
confusing.
<head>
<title>something</title>
<script src="index.dart"></script> <!-- look here -->
<script src="packages/browser/dart.js"></script>
</head>
Now, I want to run some transformation on index.dart as part of the build
process. However, since I can't replace index.dart, I have to write it out
to another file ...let's say it's index.processed.dart. Now, the HTML file
needs to be rewritten to reference the new file...but files can't be
overwritten. So in the end, I'd have to change index.html to something else.
Of course, this isn't really that practical. I'm pretty sure there has to
be some way of doing this simple workflow, but I just can't figure out how.
:/
Yeah, that is a challenge. For what it's worth, this use case is exactly
why the old barback build system *does* let you overwrite files, even
though supporting that causes a lot of other complexity.
I'm not sure what the idiomatic solution for this is with the new build
system. I think what you'd probably do is in your index.html file,
reference the file that *will* be built — the output file at its new
location — and not the original input file.
Cheers!
– bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Nate Bosch' via Dart Misc
2017-12-08 20:29:32 UTC
Permalink
This challenge definitely has come up before and it usually fits into a
pattern:

User has written some code and their entrypoint (index.dart, index.html,
etc) refers only to code they've written.
Builder wants to generate new code but without being referenced it can't be
used.

Angular, package:initialize, and dart_to_js_script_rewriter all fit this
pattern. For the most part, these patterns show up when there are two ways
of executing the code (mirrors vs no mirrors, dartium running dart vs
chrome running js) and in most cases the direction we're moving is to have
only 1 way for executing the code.

Most of the time what this means is that the user needs to write something
a bit different, and reference files they didn't write. In your example
we'd ask the user to write their html with <script
src="index.processed.dart">

We've discussed finding some way to model this with package:build but so
far we have not found anything satisfying, so we're sticking doing the
changes manually for now.
Post by Ryan Gonzalez
https://github.com/dart-lang/build
And it looks awesome! However, I'm having a hard time trying to figure out
how to use this from a practical standpoint.
- take input.dart
- do something with out
- output a new input.dart
Now, the build package has a requirement that builders can't overwrite
their inputs...which makes total sense. However, this is where things get
confusing.
<head>
<title>something</title>
<script src="index.dart"></script> <!-- look here -->
<script src="packages/browser/dart.js"></script>
</head>
Now, I want to run some transformation on index.dart as part of the build
process. However, since I can't replace index.dart, I have to write it out
to another file ...let's say it's index.processed.dart. Now, the HTML file
needs to be rewritten to reference the new file...but files can't be
overwritten. So in the end, I'd have to change index.html to something
else.
Of course, this isn't really that practical. I'm pretty sure there has to
be some way of doing this simple workflow, but I just can't figure out how.
:/
--
Ryan (ラむアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...