Skip to content

Commit

Permalink
fix(webpack): don't use default extensions if it's empty (fixes #855)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anber committed Nov 28, 2021
1 parent 1e382d8 commit 94e6486
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/webpack4-loader/src/index.ts
Expand Up @@ -80,6 +80,12 @@ export default function webpack4Loader(
// This API is used by many loaders/plugins, so hope we're safe for a while
const webpackResolveOptions = this._compilation?.options.resolve;

// Resolved configuration contains empty list of extensions as a default value
// https://github.com/callstack/linaria/issues/855
if (webpackResolveOptions.extensions?.length === 0) {
delete webpackResolveOptions.extensions;
}

// Let's try to create a resolver with the webpack config
let resolveSync = enhancedResolve.create.sync({
...resolveOptionsDefaults,
Expand Down
6 changes: 6 additions & 0 deletions packages/webpack5-loader/src/index.ts
Expand Up @@ -68,6 +68,12 @@ export default function webpack5Loader(
// This API is used by many loaders/plugins, so hope we're safe for a while
const webpackResolveOptions = this._compilation?.options.resolve;

// Resolved configuration contains empty list of extensions as a default value
// https://github.com/callstack/linaria/issues/855
if (webpackResolveOptions.extensions?.length === 0) {
delete webpackResolveOptions.extensions;
}

// Let's try to create a resolver with the webpack config
let resolveSync = enhancedResolve.create.sync({
...resolveOptionsDefaults,
Expand Down

0 comments on commit 94e6486

Please sign in to comment.