-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from ember-template-tag to content-tag
- Loading branch information
1 parent
b069062
commit 2513f62
Showing
7 changed files
with
38 additions
and
56 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 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 |
---|---|---|
@@ -1,19 +1,26 @@ | ||
// @ts-ignore | ||
import {transform, parseTemplates} from 'ember-template-tag' | ||
import {parseFile as parseHbsFile} from './hbs_extractor' | ||
import {parseScript} from './parse_script' | ||
import { parseFile as parseHbsFile } from './hbs_extractor' | ||
import { parseScript } from './parse_script' | ||
// We can't use an import here because the gts_extractor.ts file | ||
// is FAKE TS -- in that it's actually CJS. | ||
// | ||
// So we have to use require because content-tag is a real type=module package | ||
// and we need TypeScript to recognize that it has to choose the node/require | ||
// condition of package.json#exports | ||
// https://github.com/embroider-build/content-tag/blob/main/package.json#L18 | ||
let { Preprocessor } = require('content-tag'); | ||
let p = new Preprocessor(); | ||
|
||
export function parseFile(source: string, fileName: string, options: any) { | ||
const scriptParseFn = parseScript(options, fileName) | ||
const {output: transformedSource} = transform({ | ||
input: source, | ||
relativePath: '', | ||
}) | ||
const transformedSource = p.process(source, { filename: fileName }) | ||
|
||
scriptParseFn(transformedSource) | ||
|
||
// extract template from transformed source to then run through hbs processor | ||
const [templateSource] = parseTemplates(source, '') | ||
const parseResult = p.parse(source, { filename: fileName }); | ||
|
||
for (let parsed of parseResult) { | ||
parseHbsFile(parsed.contents, fileName, options) | ||
} | ||
|
||
parseHbsFile(templateSource.contents, fileName, options) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.