rspeedy-plugin-vanilla-extract 0.2.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/README.md +30 -0
- package/dist/index.cjs +54 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +54 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# rspeedy-plugin-vanilla-extract
|
|
2
|
+
|
|
3
|
+
Use [vanilla-extract](https://vanilla-extract.style/) with Rspeedy through an
|
|
4
|
+
Rsbuild plugin. This wraps `@vanilla-extract/webpack-plugin` and adds an SWC
|
|
5
|
+
loader to vanilla-extract child compilers.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install rspeedy-plugin-vanilla-extract @rsbuild/core webpack
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Use
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { pluginVanillaExtract } from "rspeedy-plugin-vanilla-extract";
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
plugins: [pluginVanillaExtract({})],
|
|
20
|
+
};
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Pass vanilla-extract webpack plugin options to `pluginVanillaExtract` as needed.
|
|
24
|
+
|
|
25
|
+
## Release
|
|
26
|
+
|
|
27
|
+
Run `yarn changeset` with each user-facing change. A push to `main` opens or
|
|
28
|
+
updates a version pull request. After it is merged, GitHub Actions publishes
|
|
29
|
+
the version to npm using trusted publishing. The first version must be
|
|
30
|
+
published manually before npm can be configured to trust the workflow.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var webpackPlugin = require('@vanilla-extract/webpack-plugin');
|
|
2
|
+
|
|
3
|
+
class VanillaExtractRspeedyCompatPlugin {
|
|
4
|
+
apply(compiler) {
|
|
5
|
+
compiler.hooks.thisCompilation.tap("VanillaExtractTypeScript", (compilation)=>{
|
|
6
|
+
const original = compilation.createChildCompiler.bind(compilation);
|
|
7
|
+
compilation.createChildCompiler = (name, outputOptions, plugins)=>{
|
|
8
|
+
const childCompiler = original(name, outputOptions, plugins);
|
|
9
|
+
if (!name?.startsWith("vanilla-extract-compiler")) {
|
|
10
|
+
return childCompiler;
|
|
11
|
+
}
|
|
12
|
+
childCompiler.options.module.rules ??= [];
|
|
13
|
+
childCompiler.options.module.rules.unshift({
|
|
14
|
+
test: /\.[cm]?[jt]sx?$/,
|
|
15
|
+
use: [
|
|
16
|
+
{
|
|
17
|
+
loader: "builtin:swc-loader",
|
|
18
|
+
options: {
|
|
19
|
+
jsc: {
|
|
20
|
+
parser: {
|
|
21
|
+
syntax: "typescript",
|
|
22
|
+
tsx: false,
|
|
23
|
+
decorators: true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
return childCompiler;
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates an Rsbuild plugin that enables vanilla-extract and applies
|
|
38
|
+
* Rspeedy compatibility adjustments.
|
|
39
|
+
*
|
|
40
|
+
* @param options Configuration for the underlying vanilla-extract webpack plugin.
|
|
41
|
+
* @returns Rsbuild plugin definition for vanilla-extract integration.
|
|
42
|
+
*/ function pluginVanillaExtract(options) {
|
|
43
|
+
return {
|
|
44
|
+
name: "rspeedy-plugin-vanilla-extract",
|
|
45
|
+
setup (api) {
|
|
46
|
+
api.modifyRspackConfig((config)=>{
|
|
47
|
+
config.plugins.push(new webpackPlugin.VanillaExtractPlugin(options));
|
|
48
|
+
config.plugins.push(new VanillaExtractRspeedyCompatPlugin());
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.pluginVanillaExtract = pluginVanillaExtract;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
import { VanillaExtractPlugin } from '@vanilla-extract/webpack-plugin';
|
|
3
|
+
|
|
4
|
+
type VanillaExtractWebpackPluginOptions = typeof VanillaExtractPlugin extends new (options: infer O) => unknown ? O : never;
|
|
5
|
+
/**
|
|
6
|
+
* Options forwarded to `@vanilla-extract/webpack-plugin`.
|
|
7
|
+
*/
|
|
8
|
+
type PluginVanillaExtractOptions = VanillaExtractWebpackPluginOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Creates an Rsbuild plugin that enables vanilla-extract and applies
|
|
11
|
+
* Rspeedy compatibility adjustments.
|
|
12
|
+
*
|
|
13
|
+
* @param options Configuration for the underlying vanilla-extract webpack plugin.
|
|
14
|
+
* @returns Rsbuild plugin definition for vanilla-extract integration.
|
|
15
|
+
*/
|
|
16
|
+
declare function pluginVanillaExtract(options: PluginVanillaExtractOptions): RsbuildPlugin;
|
|
17
|
+
|
|
18
|
+
export { pluginVanillaExtract };
|
|
19
|
+
export type { PluginVanillaExtractOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { VanillaExtractPlugin } from '@vanilla-extract/webpack-plugin';
|
|
2
|
+
|
|
3
|
+
class VanillaExtractRspeedyCompatPlugin {
|
|
4
|
+
apply(compiler) {
|
|
5
|
+
compiler.hooks.thisCompilation.tap("VanillaExtractTypeScript", (compilation)=>{
|
|
6
|
+
const original = compilation.createChildCompiler.bind(compilation);
|
|
7
|
+
compilation.createChildCompiler = (name, outputOptions, plugins)=>{
|
|
8
|
+
const childCompiler = original(name, outputOptions, plugins);
|
|
9
|
+
if (!name?.startsWith("vanilla-extract-compiler")) {
|
|
10
|
+
return childCompiler;
|
|
11
|
+
}
|
|
12
|
+
childCompiler.options.module.rules ??= [];
|
|
13
|
+
childCompiler.options.module.rules.unshift({
|
|
14
|
+
test: /\.[cm]?[jt]sx?$/,
|
|
15
|
+
use: [
|
|
16
|
+
{
|
|
17
|
+
loader: "builtin:swc-loader",
|
|
18
|
+
options: {
|
|
19
|
+
jsc: {
|
|
20
|
+
parser: {
|
|
21
|
+
syntax: "typescript",
|
|
22
|
+
tsx: false,
|
|
23
|
+
decorators: true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
return childCompiler;
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates an Rsbuild plugin that enables vanilla-extract and applies
|
|
38
|
+
* Rspeedy compatibility adjustments.
|
|
39
|
+
*
|
|
40
|
+
* @param options Configuration for the underlying vanilla-extract webpack plugin.
|
|
41
|
+
* @returns Rsbuild plugin definition for vanilla-extract integration.
|
|
42
|
+
*/ function pluginVanillaExtract(options) {
|
|
43
|
+
return {
|
|
44
|
+
name: "rspeedy-plugin-vanilla-extract",
|
|
45
|
+
setup (api) {
|
|
46
|
+
api.modifyRspackConfig((config)=>{
|
|
47
|
+
config.plugins.push(new VanillaExtractPlugin(options));
|
|
48
|
+
config.plugins.push(new VanillaExtractRspeedyCompatPlugin());
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { pluginVanillaExtract };
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rspeedy-plugin-vanilla-extract",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "vanilla-extract integration for Rspeedy",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/tonyfromundefined/rspeedy-plugin-vanilla-extract.git"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "bunchee",
|
|
25
|
+
"dev": "bunchee --watch",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"version-packages": "changeset version"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@vanilla-extract/webpack-plugin": "^2.3.26"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@changesets/cli": "^2.29.8",
|
|
34
|
+
"@rsbuild/core": "^1",
|
|
35
|
+
"bunchee": "^6.9.3",
|
|
36
|
+
"typescript": "^5.9.3",
|
|
37
|
+
"webpack": "^5.105.4"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@rsbuild/core": "^1",
|
|
41
|
+
"webpack": "^5"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"registry": "https://registry.npmjs.org/"
|
|
46
|
+
},
|
|
47
|
+
"packageManager": "yarn@4.18.0"
|
|
48
|
+
}
|