@rsbuild/plugin-stylus 0.6.14 → 0.7.0-beta.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/dist/index.cjs +69 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.js +24 -51
- package/package.json +10 -10
- package/dist/index.mjs +0 -56
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
pluginStylus: () => pluginStylus
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
var import_core = require("@rsbuild/core");
|
|
37
|
+
var import_shared = require("@rsbuild/shared");
|
|
38
|
+
function pluginStylus(options) {
|
|
39
|
+
return {
|
|
40
|
+
name: import_core.PLUGIN_STYLUS_NAME,
|
|
41
|
+
setup(api) {
|
|
42
|
+
const STYLUS_REGEX = /\.styl(us)?$/;
|
|
43
|
+
api.modifyBundlerChain(async (chain, utils) => {
|
|
44
|
+
const config = api.getNormalizedConfig();
|
|
45
|
+
const mergedOptions = (0, import_shared.mergeChainedOptions)({
|
|
46
|
+
defaults: {
|
|
47
|
+
sourceMap: config.output.sourceMap.css
|
|
48
|
+
},
|
|
49
|
+
options,
|
|
50
|
+
mergeFn: import_shared.deepmerge
|
|
51
|
+
});
|
|
52
|
+
const rule = chain.module.rule(utils.CHAIN_ID.RULE.STYLUS).test(STYLUS_REGEX);
|
|
53
|
+
const { applyCSSRule } = await import("@rsbuild/core/internal");
|
|
54
|
+
await applyCSSRule({
|
|
55
|
+
rule,
|
|
56
|
+
config,
|
|
57
|
+
context: api.context,
|
|
58
|
+
utils,
|
|
59
|
+
importLoaders: 2
|
|
60
|
+
});
|
|
61
|
+
rule.use(utils.CHAIN_ID.USE.STYLUS).loader(require.resolve("stylus-loader")).options(mergedOptions);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
pluginStylus
|
|
69
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
|
|
1
|
+
import { type RsbuildPlugin } from '@rsbuild/core';
|
|
3
2
|
type StylusOptions = {
|
|
4
3
|
use?: string[];
|
|
5
4
|
include?: string;
|
|
@@ -18,7 +17,6 @@ type StylusLoaderOptions = {
|
|
|
18
17
|
*/
|
|
19
18
|
sourceMap?: boolean;
|
|
20
19
|
};
|
|
21
|
-
type PluginStylusOptions = StylusLoaderOptions;
|
|
22
|
-
declare function pluginStylus(options?: PluginStylusOptions): RsbuildPlugin;
|
|
23
|
-
|
|
24
|
-
export { type PluginStylusOptions, pluginStylus };
|
|
20
|
+
export type PluginStylusOptions = StylusLoaderOptions;
|
|
21
|
+
export declare function pluginStylus(options?: PluginStylusOptions): RsbuildPlugin;
|
|
22
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,76 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
var require = createRequire(import.meta['url']);
|
|
29
3
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
4
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
+
}) : x)(function(x) {
|
|
7
|
+
if (typeof require !== "undefined")
|
|
8
|
+
return require.apply(this, arguments);
|
|
9
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
34
10
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
11
|
+
|
|
12
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
14
|
+
import path from "path";
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
import { PLUGIN_STYLUS_NAME } from "@rsbuild/core";
|
|
18
|
+
import { deepmerge, mergeChainedOptions } from "@rsbuild/shared";
|
|
38
19
|
function pluginStylus(options) {
|
|
39
20
|
return {
|
|
40
|
-
name:
|
|
21
|
+
name: PLUGIN_STYLUS_NAME,
|
|
41
22
|
setup(api) {
|
|
42
23
|
const STYLUS_REGEX = /\.styl(us)?$/;
|
|
43
24
|
api.modifyBundlerChain(async (chain, utils) => {
|
|
44
25
|
const config = api.getNormalizedConfig();
|
|
45
|
-
const mergedOptions =
|
|
26
|
+
const mergedOptions = mergeChainedOptions({
|
|
46
27
|
defaults: {
|
|
47
28
|
sourceMap: config.output.sourceMap.css
|
|
48
29
|
},
|
|
49
30
|
options,
|
|
50
|
-
mergeFn:
|
|
31
|
+
mergeFn: deepmerge
|
|
51
32
|
});
|
|
52
33
|
const rule = chain.module.rule(utils.CHAIN_ID.RULE.STYLUS).test(STYLUS_REGEX);
|
|
53
|
-
const {
|
|
54
|
-
|
|
55
|
-
await applyBaseCSSRule({
|
|
34
|
+
const { applyCSSRule } = await import("@rsbuild/core/internal");
|
|
35
|
+
await applyCSSRule({
|
|
56
36
|
rule,
|
|
57
37
|
config,
|
|
58
38
|
context: api.context,
|
|
59
39
|
utils,
|
|
60
40
|
importLoaders: 2
|
|
61
41
|
});
|
|
62
|
-
rule.use(utils.CHAIN_ID.USE.STYLUS).loader(
|
|
63
|
-
});
|
|
64
|
-
api.modifyRspackConfig(async (rspackConfig) => {
|
|
65
|
-
const { applyCSSModuleRule } = await import("@rsbuild/core/internal");
|
|
66
|
-
const config = api.getNormalizedConfig();
|
|
67
|
-
const rules = rspackConfig.module?.rules;
|
|
68
|
-
applyCSSModuleRule(rules, STYLUS_REGEX, config);
|
|
42
|
+
rule.use(utils.CHAIN_ID.USE.STYLUS).loader(__require.resolve("stylus-loader")).options(mergedOptions);
|
|
69
43
|
});
|
|
70
44
|
}
|
|
71
45
|
};
|
|
72
46
|
}
|
|
73
|
-
|
|
74
|
-
0 && (module.exports = {
|
|
47
|
+
export {
|
|
75
48
|
pluginStylus
|
|
76
|
-
}
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-stylus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-beta.0",
|
|
4
4
|
"description": "Stylus plugin for Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"directory": "packages/plugin-stylus"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"type": "
|
|
12
|
+
"type": "module",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"import": "./dist/index.
|
|
17
|
-
"
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
"main": "./dist/index.
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"files": [
|
|
23
23
|
"dist"
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"stylus": "0.63.0",
|
|
27
27
|
"stylus-loader": "8.1.0",
|
|
28
|
-
"@rsbuild/shared": "0.
|
|
28
|
+
"@rsbuild/shared": "0.7.0-beta.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "^5.4.2",
|
|
32
32
|
"webpack": "^5.91.0",
|
|
33
|
-
"@rsbuild/core": "0.
|
|
34
|
-
"@rsbuild/webpack": "0.
|
|
35
|
-
"@scripts/test-helper": "0.
|
|
33
|
+
"@rsbuild/core": "0.7.0-beta.0",
|
|
34
|
+
"@rsbuild/webpack": "0.7.0-beta.0",
|
|
35
|
+
"@scripts/test-helper": "0.7.0-beta.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@rsbuild/core": "^0.
|
|
38
|
+
"@rsbuild/core": "^0.7.0-beta.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public",
|
package/dist/index.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module';
|
|
2
|
-
var require = createRequire(import.meta['url']);
|
|
3
|
-
|
|
4
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
-
}) : x)(function(x) {
|
|
7
|
-
if (typeof require !== "undefined")
|
|
8
|
-
return require.apply(this, arguments);
|
|
9
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.49.2_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
13
|
-
import { fileURLToPath } from "url";
|
|
14
|
-
import path from "path";
|
|
15
|
-
|
|
16
|
-
// src/index.ts
|
|
17
|
-
import { PLUGIN_STYLUS_NAME } from "@rsbuild/core";
|
|
18
|
-
import { deepmerge, mergeChainedOptions } from "@rsbuild/shared";
|
|
19
|
-
function pluginStylus(options) {
|
|
20
|
-
return {
|
|
21
|
-
name: PLUGIN_STYLUS_NAME,
|
|
22
|
-
setup(api) {
|
|
23
|
-
const STYLUS_REGEX = /\.styl(us)?$/;
|
|
24
|
-
api.modifyBundlerChain(async (chain, utils) => {
|
|
25
|
-
const config = api.getNormalizedConfig();
|
|
26
|
-
const mergedOptions = mergeChainedOptions({
|
|
27
|
-
defaults: {
|
|
28
|
-
sourceMap: config.output.sourceMap.css
|
|
29
|
-
},
|
|
30
|
-
options,
|
|
31
|
-
mergeFn: deepmerge
|
|
32
|
-
});
|
|
33
|
-
const rule = chain.module.rule(utils.CHAIN_ID.RULE.STYLUS).test(STYLUS_REGEX);
|
|
34
|
-
const { bundlerType } = api.context;
|
|
35
|
-
const { applyBaseCSSRule } = await (bundlerType === "webpack" ? import("@rsbuild/webpack/plugin-css") : import("@rsbuild/core/internal"));
|
|
36
|
-
await applyBaseCSSRule({
|
|
37
|
-
rule,
|
|
38
|
-
config,
|
|
39
|
-
context: api.context,
|
|
40
|
-
utils,
|
|
41
|
-
importLoaders: 2
|
|
42
|
-
});
|
|
43
|
-
rule.use(utils.CHAIN_ID.USE.STYLUS).loader(__require.resolve("stylus-loader")).options(mergedOptions);
|
|
44
|
-
});
|
|
45
|
-
api.modifyRspackConfig(async (rspackConfig) => {
|
|
46
|
-
const { applyCSSModuleRule } = await import("@rsbuild/core/internal");
|
|
47
|
-
const config = api.getNormalizedConfig();
|
|
48
|
-
const rules = rspackConfig.module?.rules;
|
|
49
|
-
applyCSSModuleRule(rules, STYLUS_REGEX, config);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
pluginStylus
|
|
56
|
-
};
|