Skip to content

Commit

Permalink
build: enable compile of esm imports
Browse files Browse the repository at this point in the history
  • Loading branch information
KatoakDR committed Feb 18, 2024
1 parent 8e0b3e5 commit 849c9d7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import webpack from 'webpack';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log('***', {
__dirname,
});

dotenv.config();

Expand Down Expand Up @@ -53,6 +50,11 @@ const nextConfig = {
* https:/vercel/next.js/issues/57876
*/
webpackBuildWorker: true,
/**
* Support ESM-style imports that are fully specified with file extensions.
* https:/vercel/next.js/issues/41961
*/
fullySpecified: true,
},

compiler: {
Expand Down Expand Up @@ -214,6 +216,16 @@ const nextConfig = {
}
config.resolve.mainFields = ['module', 'main'];

// Add extension aliases to support ESM-style imports.
// https:/vercel/next.js/issues/41961
// https:/webpack/webpack/issues/13252#issuecomment-1824282100
config.resolve.extensionAlias = {
'.js': ['.ts', '.tsx', '.js', '.jsx'],
'.jsx': ['.tsx', '.jsx'],
'.mjs': ['.mts', '.mjs'],
'.cjs': ['.cts', '.cjs'],
};

return config;
},
};
Expand Down

0 comments on commit 849c9d7

Please sign in to comment.