-
Notifications
You must be signed in to change notification settings - Fork 643
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
set writeToDisk to false by default #365
Comments
There are a few reasons we have kept
Since disabling @mlrawlings @philidem any thoughts? |
@patrick-steele-idem Do we have to compile |
@hustcer templates should always be compiled on the server. When you call |
@patrick-steele-idem I see, thanks. |
@patrick-steele-idem I think I'm in favor of making On the other hand, it's extremely easy to en-able |
FWIW the surprise appearance of the compiled template as a Easy fixes, but now a little pile of them :) All that said, Marko is awesome and I think helping new users to avoid these surprises can only be a good thing. |
I would agree that it would be nice to remove these files by default if only because it makes things seem simpler. I will say though, that these compiled output files were extremely helpful in understanding how The other concern I have is that runtime errors will reference a line/column in the generated Potential solutions:
|
@mlrawlings I completely agree that the Writing out on error may be more convenient, but it would also result in files sometimes appearing with little or no explanation and littering the project folders, which could confuse new users even more. I would be very interested in source maps, though I vaguely remember seeing discussion in an issue somewhere about them being too difficult to implement. |
@Hesulan Regarding source maps, our parser already has line/column start/end positions for every tag/attribute/etc. so that's definitely a good starting point and I'm thinking with the changes made to the way we generate code in v4, it might not be too difficult to get the code writer to map changes back to the positions of the nodes its writing. Then we would need some kind of way to track where newly generated nodes came from. This would probably require the core transforms and user-generated transforms to give the compiler hints about what it's doing. This would be especially true when custom parsing tag/attribute argument expressions. I actually just recently added a I definitely think we can get this to work. We just need the time to spend on it. In the short-term, maybe controlling
or something more generic like:
|
@mlrawlings I really like the idea of using an environment variable, especially since the output files are only really used for production and debugging, and anyone worried about production start-up time should probably be compiling during a build step instead. And I'd love to see the compiler keep better track of where the code came from. That might also help with things like #247. |
The environment variable might have too great an effect. My personal primary use case is inspecting the generated file of only the template I'm working with. The environment variable feature would generate all files in the project, wouldn't it? |
@mindeavor I'm thinking the environment variable would probably just switch If you need to compile only a specific template, you can either execute ./node_modules/.bin/markoc ./path/to/template.marko in a shell, or toggle require('marko/compiler').defaultOptions.writeToDisk = true;
var template = require('./path/to/template.marko');
require('marko/compiler').defaultOptions.writeToDisk = false; I'm not aware of any hooks or methods in the API to write a specific template to disk, but that's probably worth considering even if the default value of |
I see. Personally I think it'd be great if you could add something to the code like: <script>
module.exports = {
debug: true,
onInput(attrs) {
// ...
}
}
</script> where |
That's an interesting thought @mindeavor. It's a little more verbose, but a tag such as one of the following would be easier to implement:: <write-to-disk/>
<!-- or -->
<marko-compiler write-to-disk/>
<!-- or -->
<marko-debug/>
<!-- or -->
<marko-compiler debug/>
<div>
Hello ${data.name}
</div> |
@patrick-steele-idem That's exactly what I was just thinking. Perhaps this would be a good first use case for the |
Yes, now that you mention it, a tag would be better. That way you can debug whether or not you have a |
Blocked by sourcemap support: #868 |
This is now the case in Marko 5. |
As services like https://zeit.co/now become more ubiquitous, and writing to disk in an app server becomes less kosher, this seems like a better option.
I'm having to manually load/pass-through my includes right now just so I can set writeToDisk to false, and having to set writeToDisk adds a bit more noise to my code.
My 2c. :)
The text was updated successfully, but these errors were encountered: