Skip to content

Commit

Permalink
Merge pull request #24 from mbland/handlebars-disable-source-maps
Browse files Browse the repository at this point in the history
Return compiled Handlebars string, no source maps
  • Loading branch information
mbland authored Nov 30, 2023
2 parents f164d10 + 4428456 commit 87d3139
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions strcalc/src/main/frontend/rollup-plugin-handlebars-precompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ class PluginImpl {
this.#isPartial = createFilter(options.partials || DEFAULT_PARTIALS)
this.#partialName = options.partialName || DEFAULT_PARTIAL_NAME
this.#partialPath = options.partialPath || DEFAULT_PARTIAL_PATH

if (this.#options.compiler) {
delete this.#options.compiler.srcName
delete this.#options.compiler.destName
}
}

hasHelpers() { return this.#helpers.length }
Expand All @@ -112,16 +117,14 @@ class PluginImpl {
const collector = new PartialCollector()
collector.accept(ast)

return {
code: [
IMPORT_HANDLEBARS,
...(this.hasHelpers() ? [ IMPORT_HELPERS ] : []),
...collector.partials.map(p => `import '${this.#partialPath(p, id)}'`),
`const Template = Handlebars.template(${tmpl})`,
'export default Template',
...(this.#isPartial(id) ? [ this.partialRegistration(id) ] : [])
].join('\n')
}
return [
IMPORT_HANDLEBARS,
...(this.hasHelpers() ? [ IMPORT_HELPERS ] : []),
...collector.partials.map(p => `import '${this.#partialPath(p, id)}'`),
`const Template = Handlebars.template(${tmpl})`,
'export default Template',
...(this.#isPartial(id) ? [ this.partialRegistration(id) ] : [])
].join('\n')
}

partialRegistration(id) {
Expand Down

0 comments on commit 87d3139

Please sign in to comment.