Skip to content

Commit

Permalink
fix(webpack-loader5): resolve to ES modules instead of CJS (#1339)
Browse files Browse the repository at this point in the history
* fix(webpack-loader5): resolve to ES modules instead of CJS

* Create chilly-foxes-smash.md
  • Loading branch information
layershifter committed Sep 19, 2023
1 parent 16320d7 commit f3a4f2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/chilly-foxes-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linaria/webpack5-loader": patch
---

fix(webpack-loader5): resolve to ES modules instead of CJS
3 changes: 2 additions & 1 deletion packages/webpack5-loader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ const webpack5Loader: Loader = function webpack5LoaderPlugin(
} = this.getOptions() || {};

const outputFileName = this.resourcePath.replace(/\.[^.]+$/, extension);
const resolveModule = this.getResolve({ dependencyType: 'esm' });

const asyncResolve = (token: string, importer: string): Promise<string> => {
const context = path.isAbsolute(importer)
? path.dirname(importer)
: path.join(process.cwd(), path.dirname(importer));
return new Promise((resolve, reject) => {
this.resolve(context, token, (err, result) => {
resolveModule(context, token, (err, result) => {
if (err) {
reject(err);
} else if (result) {
Expand Down

0 comments on commit f3a4f2a

Please sign in to comment.