Skip to content

Commit

Permalink
allow to compile mjs js and jsx (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed May 24, 2024
1 parent 64dab11 commit 574056e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/next-yak/withYak/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ const currentDir =
? __dirname
: dirname(fileURLToPath(import.meta.url));

export type YakConfigOptions = { contextPath?: string };
export type YakConfigOptions = {
extensions?: string[];
contextPath?: string;
};

const addYak = (yakOptions: YakConfigOptions, nextConfig: NextConfig) => {
const previousConfig = nextConfig.webpack;
nextConfig.webpack = (webpackConfig, options) => {
if (previousConfig) {
webpackConfig = previousConfig(webpackConfig, options);
}

const compiledExtensions = yakOptions.extensions || ["ts", "tsx"];
const extensionFilterRegex = new RegExp(
`\\.(${compiledExtensions.join("|")})$`,
);
webpackConfig.module.rules.push({
test: /\.tsx?$/,
test: extensionFilterRegex,
loader: path.join(currentDir, "../loaders/tsloader.cjs"),
options: yakOptions,
issuerLayer: {
Expand Down

0 comments on commit 574056e

Please sign in to comment.