Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(webpack): pass all user resolve options to loader (fixes #658) (#830
)

* fix(webpack): pass all user resolve options to loader (fixes #658)
* fix(webpack):pass all user resolve options to loader(webpack 4, fixes #658)
* fix(webpack): override mainFields (shaker can't work with es)
  • Loading branch information
5angel committed Sep 2, 2021
1 parent eed92b1 commit a0590e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
13 changes: 2 additions & 11 deletions packages/webpack4-loader/src/index.ts
Expand Up @@ -44,11 +44,6 @@ export default function webpack4Loader(

EvalCache.clearForFile(this.resourcePath);

const resolveOptionsDefaults = {
conditionNames: ['require'],
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
};

const {
sourceMap = undefined,
cacheDirectory = '.linaria-cache',
Expand Down Expand Up @@ -80,13 +75,9 @@ export default function webpack4Loader(
// Another option is to read the webpack.config.js, but it won't work for programmatic usage
// This API is used by many loaders/plugins, so hope we're safe for a while
{
...resolveOptionsDefaults,
...((this._compilation?.options.resolve && {
alias: this._compilation.options.resolve.alias,
modules: this._compilation.options.resolve.modules,
}) ||
{}),
...(this._compilation?.options.resolve ?? {}),
...resolveOptions,
mainFields: ['main'],
}
);

Expand Down
13 changes: 2 additions & 11 deletions packages/webpack5-loader/src/index.ts
Expand Up @@ -32,11 +32,6 @@ export default function webpack5Loader(

EvalCache.clearForFile(this.resourcePath);

const resolveOptionsDefaults = {
conditionNames: ['require'],
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
};

const {
sourceMap = undefined,
cacheDirectory = '.linaria-cache',
Expand Down Expand Up @@ -68,13 +63,9 @@ export default function webpack5Loader(
// Another option is to read the webpack.config.js, but it won't work for programmatic usage
// This API is used by many loaders/plugins, so hope we're safe for a while
{
...resolveOptionsDefaults,
...((this._compilation?.options.resolve && {
alias: this._compilation.options.resolve.alias,
modules: this._compilation.options.resolve.modules,
}) ||
{}),
...(this._compilation?.options.resolve ?? {}),
...resolveOptions,
mainFields: ['main'],
}
);

Expand Down

0 comments on commit a0590e5

Please sign in to comment.