Skip to content

Commit

Permalink
types: fix cache definition
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Jun 6, 2024
1 parent 76c86d6 commit fe89057
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ declare class Config extends __Config.ChainedMap<void> {
experiments(value: RspackConfig['experiments']): this;
amd(value: RspackConfig['amd']): this;
bail(value: RspackConfig['bail']): this;
cache(value: RspackConfig['cache']): this;
// TODO: Rspack does not support cache yet
cache(value: any): this;
// cache(value: RspackConfig['cache']): this;
dependencies(value: RspackConfig['dependencies']): this;
ignoreWarnings(value: RspackConfig['ignoreWarnings']): this;
loader(value: RspackConfig['loader']): this;
Expand Down
20 changes: 10 additions & 10 deletions types/test/rspack-chain-tests.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Notes: The order structure of the type check follows the order
* of this document: https://github.com/neutrinojs/webpack-chain#config
* of this document: https://github.com/neutrinojs/rspack-chain#config
*/
import { Resolver } from 'enhanced-resolve';
import * as webpack from '@rspack/core';
import * as rspack from '@rspack/core';

import Config = require('rspack-chain');

type ResolvePlugin = Exclude<
Exclude<webpack.ResolveOptions['plugins'], undefined>[number],
Exclude<rspack.ResolveOptions['plugins'], undefined>[number],
'...'
>;

Expand Down Expand Up @@ -153,7 +153,7 @@ config
.end()
.rules.delete('compile')
.end()
//** support https://webpack.js.org/configuration/module/#ruletype */
//** support https://rspack.js.org/configuration/module/#ruletype */
.rule('mjs-compile')
.test(/\.mjs$/)
.type('javascript/auto')
Expand Down Expand Up @@ -210,7 +210,7 @@ config
.end()
.preferAbsolute(false)
.plugin('foo')
.use(webpack.DefinePlugin)
.use(rspack.DefinePlugin)
.end()
.end()
// optimization
Expand All @@ -233,21 +233,21 @@ config
.set('chunks', 'all')
.end()
.minimizer('foo')
.use(webpack.DefinePlugin)
.use(rspack.DefinePlugin)
.tap((config) => [])
.end()
.end()
// plugins
.plugin('foo')
.use(webpack.DefinePlugin, [
.use(rspack.DefinePlugin, [
{
'process.env.NODE_ENV': '',
},
])
.end()

.plugin('bar')
.use(webpack.DefinePlugin, [
.use(rspack.DefinePlugin, [
{
'process.env.NODE_ENV': '',
},
Expand All @@ -256,7 +256,7 @@ config
.end()

.plugin('baz')
.use(webpack.DefinePlugin, [
.use(rspack.DefinePlugin, [
{
'process.env.NODE_ENV': '',
},
Expand All @@ -269,7 +269,7 @@ config
.end()

.plugin('asObject')
.use({ apply: (compiler: webpack.Compiler) => {} })
.use({ apply: (compiler: rspack.Compiler) => {} })
.end()

.plugins.delete('foo')
Expand Down

0 comments on commit fe89057

Please sign in to comment.