Skip to content

Commit

Permalink
Merge pull request #1713 from embroider-build/fix-babel-config
Browse files Browse the repository at this point in the history
esbuild: fix babel config location
  • Loading branch information
mansona authored Dec 7, 2023
2 parents b446d89 + 50598f2 commit b6c717f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/vite/src/esbuild-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { readFileSync, readJSONSync } from 'fs-extra';
import { EsBuildModuleRequest } from './esbuild-request';
import assertNever from 'assert-never';
import { dirname, resolve } from 'path';
import { dirname, resolve, join } from 'path';
import { hbsToJS } from '@embroider/core';
import { Preprocessor } from 'content-tag';

Expand Down Expand Up @@ -51,7 +51,10 @@ export function esBuildResolver(root = process.cwd()): EsBuildPlugin {
build.onLoad({ filter: /\.gjs$/ }, async ({ path: filename }) => {
const code = readFileSync(filename, 'utf8');

const result = transform(preprocessor.process(code, filename), { configFile: 'babel.config.js', filename });
const result = transform(preprocessor.process(code, filename), {
configFile: join(process.cwd(), 'babel.config.js'),
filename,
});

if (!result || !result.code) {
throw new Error(`Failed to load file ${filename} in esbuild-hbs-loader`);
Expand All @@ -65,7 +68,7 @@ export function esBuildResolver(root = process.cwd()): EsBuildPlugin {
build.onLoad({ filter: /\.hbs$/ }, async ({ path: filename }) => {
const code = readFileSync(filename, 'utf8');

const result = transform(hbsToJS(code), { configFile: 'babel.config.js', filename });
const result = transform(hbsToJS(code), { configFile: join(process.cwd(), 'babel.config.js'), filename });

if (!result || !result.code) {
throw new Error(`Failed to load file ${filename} in esbuild-hbs-loader`);
Expand Down

0 comments on commit b6c717f

Please sign in to comment.