Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jul 27, 2023
1 parent a5cc621 commit 8e872c5
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 25 deletions.
1 change: 1 addition & 0 deletions packages/ember-repl/addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"broccoli-file-creator": "^2.1.1",
"change-case": "^4.1.2",
"common-tags": "^1.8.2",
"content-tag": "^1.0.1",
"line-column": "^1.0.2",
"magic-string": "^0.30.1",
"mdast": "^3.0.0",
Expand Down
31 changes: 17 additions & 14 deletions packages/ember-repl/addon/src/browser/gjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@ import { importSync } from '@embroider/macros';
import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';

// TODO: use real packages, and not these copied files from ember-template-imports
import babelPluginIntermediateGJS from './eti/babel-plugin';
import { preprocessEmbeddedTemplates } from './eti/preprocess';
import { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util';

// import babelPluginIntermediateGJS from './eti/babel-plugin';
// import { preprocessEmbeddedTemplates } from './eti/preprocess';
// import { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util';
import type { Babel } from './types';

const compiler = importSync('ember-source/dist/ember-template-compiler.js');

export function preprocess(input: string, name: string) {
let preprocessed = preprocessEmbeddedTemplates(input, {
relativePath: `${name}.js`,
includeSourceMaps: false,
includeTemplateTokens: true,
templateTag: TEMPLATE_TAG_NAME,
templateTagReplacement: TEMPLATE_TAG_PLACEHOLDER,
});
import { Preprocessor } from 'content-tag';

return preprocessed.output;
const processor = new Preprocessor();

export function preprocess(input: string, name: string) {
// let preprocessed = preprocessEmbeddedTemplates(input, {
// relativePath: `${name}.js`,
// includeSourceMaps: false,
// includeTemplateTokens: true,
// templateTag: TEMPLATE_TAG_NAME,
// templateTagReplacement: TEMPLATE_TAG_PLACEHOLDER,
// });

return processor.process(input, `${name}.js`);
}

export async function transform(
Expand All @@ -33,7 +36,7 @@ export async function transform(
return babel.transform(intermediate, {
filename: `${name}.js`,
plugins: [
[babelPluginIntermediateGJS],
// [babelPluginIntermediateGJS],
[
babelPluginEmberTemplateCompilation,
{
Expand Down
172 changes: 161 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8e872c5

Please sign in to comment.