-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Rollup plugin for HBS templates
- Loading branch information
1 parent
4af550f
commit 2bf646c
Showing
5 changed files
with
78 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/node_modules | ||
/src/**/*.js | ||
/src/**/*.d.ts | ||
/src/**/*.map | ||
/*/tests/**/*.js | ||
/*/tests/**/*.d.ts | ||
/*/tests/**/*.map |
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 @@ | ||
{ | ||
"name": "@embroider/rollup-plugin-hbs", | ||
"version": "0.42.3", | ||
"private": false, | ||
"description": "Glimmer handlebars plugin for Rollup", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/embroider-build/embroider.git", | ||
"directory": "packages/rollup-plugin-hbs" | ||
}, | ||
"license": "MIT", | ||
"author": "Alex LaFroscia", | ||
"main": "src/index.js", | ||
"files": [ | ||
"src/**/*.js", | ||
"src/**/*.d.ts", | ||
"src/**/*.js.map" | ||
], | ||
"scripts": { | ||
"prepare": "tsc" | ||
}, | ||
"peerDependencies": { | ||
"@embroider/core": "0.42.3" | ||
}, | ||
"devDependencies": { | ||
"@embroider/core": "0.42.3", | ||
"rollup": "^2.52.6", | ||
"typescript": "~4.0.0" | ||
}, | ||
"engines": { | ||
"node": "10.* || 12.* || >= 14" | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
} | ||
} |
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,25 @@ | ||
import { parse } from 'path'; | ||
import type { Plugin as RollupPlugin } from 'rollup'; | ||
import { applyVariantToTemplateCompiler, Variant } from '@embroider/core'; | ||
|
||
export interface Options { | ||
templateCompilerFile: string; | ||
variant: Variant; | ||
} | ||
|
||
export default function glimmerTemplateCompilerPlugin({ templateCompilerFile, variant }: Options): RollupPlugin { | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
const templateCompiler = applyVariantToTemplateCompiler(variant, require(templateCompilerFile)).compile; | ||
|
||
return { | ||
name: '@embroider/rollup-plugin-hbs', | ||
|
||
transform(src, id) { | ||
const parsedFilePath = parse(id); | ||
|
||
if (parsedFilePath.ext === '.hbs') { | ||
return templateCompiler(id, src); | ||
} | ||
}, | ||
}; | ||
} |
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