-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1242 from embroider-build/e-template-compilation-…
…refactor Streamline stage1 template compilation
- Loading branch information
Showing
26 changed files
with
2,595 additions
and
5,297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
150 changes: 0 additions & 150 deletions
150
packages/addon-dev/tests/template-transform-plugin.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { Node } from 'broccoli-node-api'; | ||
import Filter from 'broccoli-persistent-filter'; | ||
import { hbsToJS } from '@embroider/core'; | ||
import { join } from 'path'; | ||
|
||
export default class TemplateCompileTree extends Filter { | ||
constructor(inputTree: Node) { | ||
super(inputTree, { | ||
name: `embroider-template-compile-stage1`, | ||
persist: true, | ||
extensions: ['hbs', 'handlebars'], | ||
}); | ||
} | ||
|
||
getDestFilePath(relativePath: string, entry: Parameters<Filter['getDestFilePath']>[1]) { | ||
if (this.isDirectory(relativePath, entry)) { | ||
return null; | ||
} | ||
for (let ext of ['hbs', 'handlebars']) { | ||
if (relativePath.slice(-ext.length - 1) === '.' + ext) { | ||
// we deliberately don't chop off the .hbs before appending .js, because if | ||
// the user has both .js` and .hbs` side-by-side we don't want our new file | ||
// to collide with theirs. | ||
return relativePath + '.js'; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
processString(source: string, relativePath: string) { | ||
return hbsToJS(source, relativePath); | ||
} | ||
baseDir() { | ||
return join(__dirname, '..'); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.