-
-
Notifications
You must be signed in to change notification settings - Fork 31
Provide template compiler cache key to babel plugin. #34
Provide template compiler cache key to babel plugin. #34
Conversation
var PrecompileInlineHTMLBarsPlugin = HTMLBarsInlinePrecompilePlugin(Compiler.precompile); // jshint ignore:line | ||
var templateCompilerFullPath = require.resolve(templateCompilerPath); | ||
var templateCompilerCacheKey = fs.readFileSync(templateCompilerFullPath, { encoding: 'utf-8' }); | ||
var PrecompileInlineHTMLBarsPlugin = HTMLBarsInlinePrecompilePlugin(Compiler.precompile, templateCompilerCacheKey); // jshint ignore:line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we pass a checksum? it doesn't really matter, the file content and the checksum end up representing the exact same thing. I could go either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require('crypto').createHash('sha1').update(templateCompiler).digest('hex')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or do we expect the other side to do this. Also, should we use the entire second arg for this, or should we do:
new HTMLBarsInlinePrecompilePlugin(Compiler.precompile, { cacheKey: /* ... */ })
As it may be more self documenting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I will update to options hash.
RE: checksum vs content, it doesn't much matter to me, I'm happy to go either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RE: checksum vs content, it doesn't much matter to me, I'm happy to go either way.
lets leave it as is, it gets checksumed in the plugin serialization phase anyways correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use options hash.
2e170d0
to
0e53540
Compare
@@ -41,7 +41,7 @@ | |||
"ember-cli" | |||
], | |||
"dependencies": { | |||
"babel-plugin-htmlbars-inline-precompile": "0.0.5", | |||
"babel-plugin-htmlbars-inline-precompile": "rwjblue/babel-plugin-htmlbars-inline-precompile#cache-keys", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this for testing, will need to be updated to ^0.1.0
before releasing.
This uses the file contents as cache key for the `babel-plugin-htmlbars-inline-precompile` plugin used.
0e53540
to
0ec4aa1
Compare
@@ -37,7 +38,11 @@ module.exports = { | |||
global.EmberENV = EmberENV; | |||
|
|||
var Compiler = require(templateCompilerPath); | |||
var PrecompileInlineHTMLBarsPlugin = HTMLBarsInlinePrecompilePlugin(Compiler.precompile); // jshint ignore:line | |||
var templateCompilerFullPath = require.resolve(templateCompilerPath); | |||
var templateCompilerCacheKey = fs.readFileSync(templateCompilerFullPath, { encoding: 'utf-8' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think this is sufficient, the templateCompiler may change on each rebuild, this merely checks the cache on start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, but upon restart it will blow the async cache properly (which was not true previously). So its a tad better, but could use more work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, its better. Issue opened to track and fix :)
This uses the file contents as cache key for the
babel-plugin-htmlbars-inline-precompile
plugin used.This is based on the following PR's: