@putout/plugin-convert-webpack-to-rspack 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +184 -0
- package/lib/apply-asset-type/fixture/no-url-loader.js +13 -0
- package/lib/apply-asset-type/fixture/url-loader-fix.js +13 -0
- package/lib/apply-asset-type/fixture/url-loader.js +13 -0
- package/lib/apply-asset-type/index.js +81 -0
- package/lib/apply-library-object/fixture/library-target-fix.js +10 -0
- package/lib/apply-library-object/fixture/library-target-no-export-fix.js +9 -0
- package/lib/apply-library-object/fixture/library-target-no-export.js +7 -0
- package/lib/apply-library-object/fixture/library-target.js +8 -0
- package/lib/apply-library-object/fixture/no-library-target.js +10 -0
- package/lib/apply-library-object/index.js +59 -0
- package/lib/apply-rspack-import/fixture/no-webpack.js +3 -0
- package/lib/apply-rspack-import/fixture/webpack-import-fix.js +7 -0
- package/lib/apply-rspack-import/fixture/webpack-import.js +7 -0
- package/lib/apply-rspack-import/index.js +12 -0
- package/lib/apply-swc-loader/fixture/babel-loader-fix.js +19 -0
- package/lib/apply-swc-loader/fixture/babel-loader-options-fix.js +19 -0
- package/lib/apply-swc-loader/fixture/babel-loader-options.js +12 -0
- package/lib/apply-swc-loader/fixture/babel-loader.js +9 -0
- package/lib/apply-swc-loader/fixture/no-babel-loader.js +19 -0
- package/lib/apply-swc-loader/index.js +78 -0
- package/lib/index.js +13 -0
- package/lib/remove-webpackbar/fixture/no-webpackbar.js +7 -0
- package/lib/remove-webpackbar/fixture/webpackbar-fix.js +7 -0
- package/lib/remove-webpackbar/fixture/webpackbar.js +9 -0
- package/lib/remove-webpackbar/index.js +6 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) coderaiser
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# @putout/plugin-convert-webpack-to-rspack [![NPM version][NPMIMGURL]][NPMURL]
|
|
2
|
+
|
|
3
|
+
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-convert-webpack-to-rspack.svg?style=flat&longCache=true
|
|
4
|
+
[NPMURL]: https://npmjs.org/package/@putout/plugin-convert-webpack-to-rspack "npm"
|
|
5
|
+
|
|
6
|
+
π[**Putout**](https://github.com/coderaiser/putout) plugin to convert `webpack.config.js` to [rspack](https://rspack.dev). *Not bundled*.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm i putout @putout/plugin-convert-webpack-to-rspack -D
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
- β
[apply-rspack-import](#apply-rspack-import)
|
|
17
|
+
- β
[apply-swc-loader](#apply-swc-loader)
|
|
18
|
+
- β
[apply-asset-type](#apply-asset-type)
|
|
19
|
+
- β
[apply-library-object](#apply-library-object)
|
|
20
|
+
- β
[remove-webpackbar](#remove-webpackbar)
|
|
21
|
+
|
|
22
|
+
## Config
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"rules": {
|
|
27
|
+
"convert-webpack-to-rspack/apply-rspack-import": "on",
|
|
28
|
+
"convert-webpack-to-rspack/apply-swc-loader": "on",
|
|
29
|
+
"convert-webpack-to-rspack/apply-asset-type": "on",
|
|
30
|
+
"convert-webpack-to-rspack/apply-library-object": "on",
|
|
31
|
+
"convert-webpack-to-rspack/remove-webpackbar": "on"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## apply-rspack-import
|
|
37
|
+
|
|
38
|
+
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/6af7c06cecb5e2b5717271dddd783fcf/fb2b92aa42bb5c1dadd2d5d5fb98ca06d2b6ee0d).
|
|
39
|
+
|
|
40
|
+
### β Example of incorrect code
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import webpack from 'webpack';
|
|
44
|
+
|
|
45
|
+
const {EnvironmentPlugin} = webpack;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### β
Example of correct code
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import {rspack} from '@rspack/core';
|
|
52
|
+
|
|
53
|
+
const {EnvironmentPlugin} = rspack;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## apply-swc-loader
|
|
57
|
+
|
|
58
|
+
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/d26a479c7f677bcfe74f9f946c514983/c88686d689396c1e47b22d8aee24e737eff7e24f).
|
|
59
|
+
|
|
60
|
+
### β Example of incorrect code
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
export default {
|
|
64
|
+
module: {
|
|
65
|
+
rules: [{
|
|
66
|
+
test: /\.js$/,
|
|
67
|
+
loader: 'babel-loader',
|
|
68
|
+
}],
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### β
Example of correct code
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
export default {
|
|
77
|
+
module: {
|
|
78
|
+
rules: [{
|
|
79
|
+
test: /\.js$/,
|
|
80
|
+
loader: 'builtin:swc-loader',
|
|
81
|
+
options: {
|
|
82
|
+
jsc: {
|
|
83
|
+
parser: {
|
|
84
|
+
syntax: 'ecmascript',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
env: {
|
|
88
|
+
targets: 'defaults',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
}],
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## apply-asset-type
|
|
97
|
+
|
|
98
|
+
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/6d4152d33dd67f39ef4a1d56769dc22b/a6d7b603f326717a462c01fb9568e4f989ca7af7).
|
|
99
|
+
|
|
100
|
+
### β Example of incorrect code
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
export default {
|
|
104
|
+
module: {
|
|
105
|
+
rules: [{
|
|
106
|
+
test: /\.(png|gif|svg)$/,
|
|
107
|
+
use: {
|
|
108
|
+
loader: 'url-loader',
|
|
109
|
+
options: {
|
|
110
|
+
limit: 50_000,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
}],
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### β
Example of correct code
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
export default {
|
|
122
|
+
module: {
|
|
123
|
+
rules: [{
|
|
124
|
+
test: /\.(png|gif|svg)$/,
|
|
125
|
+
type: 'asset',
|
|
126
|
+
parser: {
|
|
127
|
+
dataUrlCondition: {
|
|
128
|
+
maxSize: 50_000,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
}],
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## apply-library-object
|
|
137
|
+
|
|
138
|
+
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/c9b85da3e385d1c254f4103db8952323/1b7c7c9e8568bba9070469ced671c1dd5022bed3).
|
|
139
|
+
|
|
140
|
+
### β Example of incorrect code
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
export default {
|
|
144
|
+
output: {
|
|
145
|
+
library: 'Deepword',
|
|
146
|
+
libraryTarget: 'var',
|
|
147
|
+
libraryExport: 'default',
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### β
Example of correct code
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
export default {
|
|
156
|
+
output: {
|
|
157
|
+
library: {
|
|
158
|
+
name: 'Deepword',
|
|
159
|
+
type: 'var',
|
|
160
|
+
export: 'default',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## remove-webpackbar
|
|
167
|
+
|
|
168
|
+
### β Example of incorrect code
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
import WebpackBar from 'webpackbar';
|
|
172
|
+
|
|
173
|
+
export default {
|
|
174
|
+
plugins: [new WebpackBar()],
|
|
175
|
+
};
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### β
Example of correct code
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
export default {
|
|
182
|
+
plugins: [],
|
|
183
|
+
};
|
|
184
|
+
```
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
template,
|
|
3
|
+
types,
|
|
4
|
+
operator,
|
|
5
|
+
} from 'putout';
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
isObjectProperty,
|
|
9
|
+
stringLiteral,
|
|
10
|
+
identifier,
|
|
11
|
+
objectProperty,
|
|
12
|
+
isStringLiteral,
|
|
13
|
+
isIdentifier,
|
|
14
|
+
} = types;
|
|
15
|
+
|
|
16
|
+
const {insertAfter, remove} = operator;
|
|
17
|
+
|
|
18
|
+
const isUse = (path) => isIdentifier(path.node.key, {
|
|
19
|
+
name: 'use',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const isOptions = (path) => isIdentifier(path.node.key, {
|
|
23
|
+
name: 'options',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const isLimit = (path) => isIdentifier(path.node.key, {
|
|
27
|
+
name: 'limit',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const isUrlLoader = (path) => isStringLiteral(path.node.value, {
|
|
31
|
+
value: 'url-loader',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const report = () => `Use rspack built-in 'asset' type instead of 'url-loader'`;
|
|
35
|
+
|
|
36
|
+
export const fix = ({path, propertyUse, propertyLimit}) => {
|
|
37
|
+
const limit = propertyLimit.node.value.extra.raw;
|
|
38
|
+
|
|
39
|
+
remove(propertyUse);
|
|
40
|
+
|
|
41
|
+
const [firstProp] = path.get('properties');
|
|
42
|
+
const propertyParser = objectProperty(identifier('parser'), template.ast(`({
|
|
43
|
+
dataUrlCondition: {
|
|
44
|
+
maxSize: ${limit},
|
|
45
|
+
},
|
|
46
|
+
})`));
|
|
47
|
+
|
|
48
|
+
const propertyType = objectProperty(identifier('type'), stringLiteral('asset'));
|
|
49
|
+
|
|
50
|
+
insertAfter(firstProp, propertyParser);
|
|
51
|
+
insertAfter(firstProp, propertyType);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const traverse = ({push}) => ({
|
|
55
|
+
ObjectExpression(path) {
|
|
56
|
+
const topProperties = path.get('properties').filter(isObjectProperty);
|
|
57
|
+
|
|
58
|
+
for (const propertyUse of topProperties) {
|
|
59
|
+
if (!isUse(propertyUse))
|
|
60
|
+
continue;
|
|
61
|
+
|
|
62
|
+
const properties = propertyUse.get('value.properties').filter(isObjectProperty);
|
|
63
|
+
|
|
64
|
+
for (const property of properties) {
|
|
65
|
+
if (!isUrlLoader(property))
|
|
66
|
+
continue;
|
|
67
|
+
|
|
68
|
+
const propertyOptions = properties.find(isOptions);
|
|
69
|
+
|
|
70
|
+
const propertyLimit = propertyOptions.get('value.properties').filter(isObjectProperty)
|
|
71
|
+
.find(isLimit);
|
|
72
|
+
|
|
73
|
+
push({
|
|
74
|
+
path,
|
|
75
|
+
propertyUse,
|
|
76
|
+
propertyLimit,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {operator, template} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {remove, replaceWith} = operator;
|
|
4
|
+
|
|
5
|
+
const isLibrary = (path) => path.get('key').isIdentifier({
|
|
6
|
+
name: 'library',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const isLibraryTarget = (path) => path.get('key').isIdentifier({
|
|
10
|
+
name: 'libraryTarget',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const isLibraryExport = (path) => path.get('key').isIdentifier({
|
|
14
|
+
name: 'libraryExport',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const report = () => `Use 'output.library' object instead of 'libraryTarget'`;
|
|
18
|
+
|
|
19
|
+
export const fix = ({libraryProp, libraryTargetProp, libraryExportProp}) => {
|
|
20
|
+
const libraryValuePath = libraryProp.get('value');
|
|
21
|
+
const name = libraryValuePath.node.value;
|
|
22
|
+
const type = libraryTargetProp.node.value.value;
|
|
23
|
+
|
|
24
|
+
remove(libraryTargetProp);
|
|
25
|
+
|
|
26
|
+
if (libraryExportProp) {
|
|
27
|
+
const exportVal = libraryExportProp.node.value.value;
|
|
28
|
+
remove(libraryExportProp);
|
|
29
|
+
replaceWith(libraryValuePath, template.ast(`({
|
|
30
|
+
name: '${name}',
|
|
31
|
+
type: '${type}',
|
|
32
|
+
export: '${exportVal}',
|
|
33
|
+
})`));
|
|
34
|
+
} else {
|
|
35
|
+
replaceWith(libraryValuePath, template.ast(`({
|
|
36
|
+
name: '${name}',
|
|
37
|
+
type: '${type}',
|
|
38
|
+
})`));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
delete libraryProp.node.loc;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const traverse = ({push}) => ({
|
|
45
|
+
ObjectExpression(path) {
|
|
46
|
+
const properties = path.get('properties');
|
|
47
|
+
const libraryTargetProp = properties.find(isLibraryTarget);
|
|
48
|
+
|
|
49
|
+
if (!libraryTargetProp)
|
|
50
|
+
return;
|
|
51
|
+
|
|
52
|
+
push({
|
|
53
|
+
path,
|
|
54
|
+
libraryProp: properties.find(isLibrary),
|
|
55
|
+
libraryTargetProp,
|
|
56
|
+
libraryExportProp: properties.find(isLibraryExport),
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {rename} = operator;
|
|
4
|
+
|
|
5
|
+
export const report = () => `Use 'rspack' instead of 'webpack'`;
|
|
6
|
+
|
|
7
|
+
export const replace = () => ({
|
|
8
|
+
'import webpack from "webpack"': (vars, path) => {
|
|
9
|
+
rename(path, 'webpack', 'rspack');
|
|
10
|
+
return 'import {rspack} from "@rspack/core"';
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
module: {
|
|
3
|
+
rules: [{
|
|
4
|
+
test: /\.js$/,
|
|
5
|
+
exclude: /node_modules/,
|
|
6
|
+
loader: 'builtin:swc-loader',
|
|
7
|
+
options: {
|
|
8
|
+
jsc: {
|
|
9
|
+
parser: {
|
|
10
|
+
syntax: 'ecmascript',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
env: {
|
|
14
|
+
targets: 'defaults',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
module: {
|
|
3
|
+
rules: [{
|
|
4
|
+
test: /\.js$/,
|
|
5
|
+
exclude: /node_modules/,
|
|
6
|
+
loader: 'builtin:swc-loader',
|
|
7
|
+
options: {
|
|
8
|
+
jsc: {
|
|
9
|
+
parser: {
|
|
10
|
+
syntax: 'ecmascript',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
env: {
|
|
14
|
+
targets: 'defaults',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
module: {
|
|
3
|
+
rules: [{
|
|
4
|
+
test: /\.js$/,
|
|
5
|
+
exclude: /node_modules/,
|
|
6
|
+
loader: 'builtin:swc-loader',
|
|
7
|
+
options: {
|
|
8
|
+
jsc: {
|
|
9
|
+
parser: {
|
|
10
|
+
syntax: 'ecmascript',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
env: {
|
|
14
|
+
targets: 'defaults',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
template,
|
|
3
|
+
operator,
|
|
4
|
+
types,
|
|
5
|
+
} from 'putout';
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
isStringLiteral,
|
|
9
|
+
isIdentifier,
|
|
10
|
+
isObjectProperty,
|
|
11
|
+
identifier,
|
|
12
|
+
objectProperty,
|
|
13
|
+
} = types;
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
insertAfter,
|
|
17
|
+
replaceWith,
|
|
18
|
+
setLiteralValue,
|
|
19
|
+
} = operator;
|
|
20
|
+
|
|
21
|
+
const SWC_OPTIONS = `({
|
|
22
|
+
jsc: {
|
|
23
|
+
parser: {
|
|
24
|
+
syntax: 'ecmascript',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
env: {
|
|
28
|
+
targets: 'defaults',
|
|
29
|
+
},
|
|
30
|
+
})`;
|
|
31
|
+
|
|
32
|
+
export const report = () => `Use 'builtin:swc-loader' instead of 'babel-loader'`;
|
|
33
|
+
|
|
34
|
+
export const fix = ({path, optionsProp}) => {
|
|
35
|
+
setLiteralValue(path, 'builtin:swc-loader');
|
|
36
|
+
|
|
37
|
+
if (optionsProp) {
|
|
38
|
+
replaceWith(optionsProp.get('value'), template.ast(SWC_OPTIONS));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const {parentPath} = path;
|
|
43
|
+
const property = objectProperty(identifier('options'), template.ast(SWC_OPTIONS));
|
|
44
|
+
|
|
45
|
+
insertAfter(parentPath, property);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const traverse = ({push}) => ({
|
|
49
|
+
ObjectExpression(path) {
|
|
50
|
+
const properties = path.get('properties').filter(isObjectProperty);
|
|
51
|
+
|
|
52
|
+
for (const prop of properties) {
|
|
53
|
+
if (!isBabelLoader(prop))
|
|
54
|
+
continue;
|
|
55
|
+
|
|
56
|
+
const loaderPath = prop.get('value');
|
|
57
|
+
|
|
58
|
+
const optionsProp = properties.find(isOptions);
|
|
59
|
+
|
|
60
|
+
push({
|
|
61
|
+
path: loaderPath,
|
|
62
|
+
optionsProp,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const isLoader = (path) => isIdentifier(path.node.key, {
|
|
69
|
+
name: 'loader',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const isOptions = (path) => isIdentifier(path.node.key, {
|
|
73
|
+
name: 'options',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const isBabelLoader = (path) => isLoader(path) && isStringLiteral(path.node.value, {
|
|
77
|
+
value: 'babel-loader',
|
|
78
|
+
});
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as applyRspackImport from './apply-rspack-import/index.js';
|
|
2
|
+
import * as applySwcLoader from './apply-swc-loader/index.js';
|
|
3
|
+
import * as applyAssetType from './apply-asset-type/index.js';
|
|
4
|
+
import * as applyLibraryObject from './apply-library-object/index.js';
|
|
5
|
+
import * as removeWebpackbar from './remove-webpackbar/index.js';
|
|
6
|
+
|
|
7
|
+
export const rules = {
|
|
8
|
+
'apply-rspack-import': applyRspackImport,
|
|
9
|
+
'apply-swc-loader': applySwcLoader,
|
|
10
|
+
'apply-asset-type': applyAssetType,
|
|
11
|
+
'apply-library-object': applyLibraryObject,
|
|
12
|
+
'remove-webpackbar': removeWebpackbar,
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@putout/plugin-convert-webpack-to-rspack",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
|
+
"description": "πPutout plugin to convert webpack config to rspack",
|
|
7
|
+
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-convert-webpack-to-rspack#readme",
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"release": false,
|
|
10
|
+
"tag": false,
|
|
11
|
+
"changelog": false,
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/coderaiser/putout.git"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "madrun test",
|
|
18
|
+
"watch:test": "madrun watch:test",
|
|
19
|
+
"lint": "madrun lint",
|
|
20
|
+
"fresh:lint": "madrun fresh:lint",
|
|
21
|
+
"lint:fresh": "madrun lint:fresh",
|
|
22
|
+
"fix:lint": "madrun fix:lint",
|
|
23
|
+
"coverage": "madrun coverage",
|
|
24
|
+
"report": "madrun report"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"putout",
|
|
28
|
+
"putout-plugin",
|
|
29
|
+
"plugin",
|
|
30
|
+
"webpack",
|
|
31
|
+
"rspack"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@putout/test": "^15.0.0",
|
|
36
|
+
"eslint": "^10.0.0",
|
|
37
|
+
"eslint-plugin-putout": "^31.0.0",
|
|
38
|
+
"madrun": "^13.0.0",
|
|
39
|
+
"nodemon": "^3.0.1",
|
|
40
|
+
"superc8": "^12.0.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"putout": ">=42"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=22"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|