Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the resolve function to be the only public api to module-resolver #1794

Merged
merged 21 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class CompatAppBuilder {
}

@Memoize()
private babelConfig(resolverConfig: CompatResolverOptions) {
private async babelConfig(resolverConfig: CompatResolverOptions) {
let babel = cloneDeep(this.compatApp.babelConfig());

if (!babel.plugins) {
Expand All @@ -429,7 +429,10 @@ export class CompatAppBuilder {
// https://github.com/webpack/webpack/issues/12154
babel.plugins.push(require.resolve('./rename-require-plugin'));

babel.plugins.push([require.resolve('babel-plugin-ember-template-compilation'), this.etcOptions(resolverConfig)]);
babel.plugins.push([
require.resolve('babel-plugin-ember-template-compilation'),
await this.etcOptions(resolverConfig),
]);

// this is @embroider/macros configured for full stage3 resolution
babel.plugins.push(...this.compatApp.macrosConfig.babelPluginConfig());
Expand Down Expand Up @@ -992,7 +995,7 @@ export class CompatAppBuilder {

let resolverConfig = this.resolverConfig(appFiles);
this.addResolverConfig(resolverConfig);
let babelConfig = this.babelConfig(resolverConfig);
let babelConfig = await this.babelConfig(resolverConfig);
this.addBabelConfig(babelConfig);
writeFileSync(
join(this.root, 'macros-config.json'),
Expand All @@ -1012,7 +1015,7 @@ export class CompatAppBuilder {
return combinePackageJSON(...pkgLayers);
}

private etcOptions(resolverConfig: CompatResolverOptions): EtcOptions {
private async etcOptions(resolverConfig: CompatResolverOptions): Promise<EtcOptions> {
let transforms = this.compatApp.htmlbarsPlugins;

let { plugins: macroPlugins, setConfig } = MacrosConfig.transforms();
Expand All @@ -1034,7 +1037,7 @@ export class CompatAppBuilder {
}

let resolver = new Resolver(resolverConfig);
let resolution = resolver.nodeResolve(
let resolution = await resolver.nodeResolve(
'ember-source/vendor/ember/ember-template-compiler',
resolvePath(this.root, 'package.json')
);
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"lodash": "^4.17.21",
"resolve": "^1.20.0",
"resolve-package-path": "^4.0.1",
"resolve.exports": "^2.0.2",
"@embroider/reverse-exports": "workspace:*",
"typescript-memoize": "^1.0.1",
"walk-sync": "^3.0.0"
Expand Down
9 changes: 1 addition & 8 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ export { default as toBroccoliPlugin } from './to-broccoli-plugin';
export { default as WaitForTrees, OutputPaths } from './wait-for-trees';
export { compile as jsHandlebarsCompile } from './js-handlebars';
export { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';
export {
Resolver,
Options as ResolverOptions,
ModuleRequest,
Resolution,
ResolverFunction,
SyncResolverFunction,
} from './module-resolver';
export { Resolver, Options as ResolverOptions, ModuleRequest, Resolution } from './module-resolver';
export { ResolverLoader } from './resolver-loader';
export { virtualContent } from './virtual-content';
export type { Engine } from './app-files';
Expand Down
Loading
Loading