Skip to content

Commit

Permalink
Merge pull request #989 from embroider-build/babel-import-util
Browse files Browse the repository at this point in the history
use babel-import-util
  • Loading branch information
ef4 authored Oct 1, 2021
2 parents f02ff6a + 31c14b5 commit 2fe80c3
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 282 deletions.
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@embroider/macros": "0.45.0",
"@embroider/shared-internals": "0.45.0",
"assert-never": "^1.2.1",
"babel-import-util": "^0.2.0",
"broccoli-node-api": "^1.7.0",
"broccoli-persistent-filter": "^3.1.2",
"broccoli-plugin": "^4.0.7",
Expand Down
89 changes: 0 additions & 89 deletions packages/core/src/babel-import-adder.ts

This file was deleted.

6 changes: 3 additions & 3 deletions packages/core/src/babel-plugin-inline-hbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { join } from 'path';
import { TemplateCompiler } from './template-compiler-common';
import { parse } from '@babel/core';
import { ResolvedDep } from './resolver';
import { ImportAdder } from './babel-import-adder';
import { ImportUtil } from 'babel-import-util';

type BabelTypes = typeof t;

Expand Down Expand Up @@ -34,7 +34,7 @@ interface State {
};
dependencies: Map<string, ResolvedDep>;
templateCompiler: TemplateCompiler | undefined;
adder: ImportAdder;
adder: ImportUtil;
}

export type Params = State['opts'];
Expand All @@ -47,7 +47,7 @@ export default function make(getCompiler: (opts: any) => TemplateCompiler) {
Program: {
enter(path: NodePath<t.Program>, state: State) {
state.dependencies = new Map();
state.adder = new ImportAdder(t, path);
state.adder = new ImportUtil(t, path);
},
exit(path: NodePath<t.Program>, state: State) {
if (state.opts.stage === 3) {
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/template-colocation-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type * as t from '@babel/types';
import { dirname } from 'path';
import { explicitRelative } from '@embroider/shared-internals';
import { PackageCache } from '@embroider/shared-internals';
import { ImportAdder } from './babel-import-adder';
import { ImportUtil } from 'babel-import-util';

type BabelTypes = typeof t;

Expand All @@ -13,7 +13,7 @@ const packageCache = PackageCache.shared('embroider-stage3');
interface State {
colocatedTemplate: string | undefined;
associate: { component: t.Identifier; template: t.Identifier } | undefined;
adder: ImportAdder;
adder: ImportUtil;
}

function setComponentTemplate(target: NodePath<t.Node>, state: State) {
Expand All @@ -26,7 +26,7 @@ export default function main(babel: unknown) {
visitor: {
Program: {
enter(path: NodePath<t.Program>, state: State) {
state.adder = new ImportAdder(t, path);
state.adder = new ImportUtil(t, path);
let filename = path.hub.file.opts.filename;

let owningPackage = packageCache.ownerOfFile(filename);
Expand Down Expand Up @@ -127,6 +127,6 @@ export default function main(babel: unknown) {
};
}

function importTemplate(target: NodePath<t.Node>, adder: ImportAdder, colocatedTemplate: string) {
function importTemplate(target: NodePath<t.Node>, adder: ImportUtil, colocatedTemplate: string) {
return adder.import(target, explicitRelative(dirname(colocatedTemplate), colocatedTemplate), 'default', 'TEMPLATE');
}
181 changes: 0 additions & 181 deletions packages/core/tests/import-adder.test.ts

This file was deleted.

Loading

0 comments on commit 2fe80c3

Please sign in to comment.