@rsbuild/plugin-stylus 1.0.0 → 1.0.1-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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Rsbuild
6
6
 
7
- Unleash the power of Rspack with the out-of-the-box build tool.
7
+ The Rspack-based build tool. It's fast, out-of-the-box and extensible.
8
8
 
9
9
  ## Documentation
10
10
 
package/dist/index.cjs ADDED
@@ -0,0 +1,71 @@
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
+ PLUGIN_STYLUS_NAME: () => PLUGIN_STYLUS_NAME,
34
+ pluginStylus: () => pluginStylus
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+ var import_deepmerge = __toESM(require("deepmerge"));
38
+ var import_reduce_configs = require("reduce-configs");
39
+ var PLUGIN_STYLUS_NAME = "rsbuild:stylus";
40
+ var pluginStylus = (options) => ({
41
+ name: PLUGIN_STYLUS_NAME,
42
+ setup(api) {
43
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment }) => {
44
+ const { config } = environment;
45
+ const mergedOptions = (0, import_reduce_configs.reduceConfigs)({
46
+ initial: {
47
+ sourceMap: config.output.sourceMap.css
48
+ },
49
+ config: options,
50
+ mergeFn: import_deepmerge.default
51
+ });
52
+ const rule = chain.module.rule(CHAIN_ID.RULE.STYLUS).test(/\.styl(us)?$/).merge({ sideEffects: true }).resolve.preferRelative(true).end();
53
+ const cssRule = chain.module.rules.get(CHAIN_ID.RULE.CSS);
54
+ for (const id of Object.keys(cssRule.uses.entries())) {
55
+ const loader = cssRule.uses.get(id);
56
+ const options2 = loader.get("options") ?? {};
57
+ const clonedOptions = (0, import_deepmerge.default)({}, options2);
58
+ if (id === CHAIN_ID.USE.CSS) {
59
+ clonedOptions.importLoaders = 2;
60
+ }
61
+ rule.use(id).loader(loader.get("loader")).options(clonedOptions);
62
+ }
63
+ rule.use(CHAIN_ID.USE.STYLUS).loader(require.resolve("stylus-loader")).options(mergedOptions);
64
+ });
65
+ }
66
+ });
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ PLUGIN_STYLUS_NAME,
70
+ pluginStylus
71
+ });
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
-
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ export declare const PLUGIN_STYLUS_NAME = "rsbuild:stylus";
3
3
  type StylusOptions = {
4
4
  use?: string[];
5
5
  include?: string;
@@ -8,11 +8,15 @@ type StylusOptions = {
8
8
  lineNumbers?: boolean;
9
9
  hoistAtrules?: boolean;
10
10
  };
11
- type StylusLoaderOptions = {
11
+ export type PluginStylusOptions = {
12
+ /**
13
+ * Options passed to Stylus.
14
+ */
12
15
  stylusOptions?: StylusOptions;
16
+ /**
17
+ * Whether to generate Source Map.
18
+ */
13
19
  sourceMap?: boolean;
14
20
  };
15
- type PluginStylusOptions = StylusLoaderOptions;
16
- declare function pluginStylus(options?: PluginStylusOptions): RsbuildPlugin;
17
-
18
- export { PluginStylusOptions, pluginStylus };
21
+ export declare const pluginStylus: (options?: PluginStylusOptions) => RsbuildPlugin;
22
+ export {};
package/dist/index.js CHANGED
@@ -1,75 +1,50 @@
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);
1
+ import { createRequire } from 'module';
2
+ var require = createRequire(import.meta['url']);
29
3
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- pluginStylus: () => pluginStylus
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
- module.exports = __toCommonJS(src_exports);
36
- var import_shared = require("@rsbuild/shared");
37
- function pluginStylus(options) {
38
- return {
39
- name: "rsbuild:stylus",
40
- setup(api) {
41
- const { bundlerType } = api.context;
42
- api.modifyBundlerChain(async (chain, utils) => {
43
- const config = api.getNormalizedConfig();
44
- const mergedOptions = (0, import_shared.mergeChainedOptions)({
45
- defaults: {
46
- sourceMap: (0, import_shared.isUseCssSourceMap)(config)
47
- },
48
- options,
49
- mergeFn: import_shared.deepmerge
50
- });
51
- const rule = chain.module.rule(utils.CHAIN_ID.RULE.STYLUS).test(import_shared.STYLUS_REGEX);
52
- const { applyBaseCSSRule } = await (bundlerType === "webpack" ? import("@rsbuild/webpack/plugin-css") : import("@rsbuild/core/rspack-plugin-css"));
53
- await applyBaseCSSRule({
54
- rule,
55
- config,
56
- context: api.context,
57
- utils,
58
- importLoaders: 2
59
- });
60
- rule.use(utils.CHAIN_ID.USE.STYLUS).loader(require.resolve("stylus-loader")).options(mergedOptions);
61
- });
62
- bundlerType === "rspack" && api.modifyRspackConfig(async (rspackConfig) => {
63
- var _a;
64
- const { applyCSSModuleRule } = await import("@rsbuild/core/rspack-plugin-css");
65
- const config = api.getNormalizedConfig();
66
- const rules = (_a = rspackConfig.module) == null ? void 0 : _a.rules;
67
- applyCSSModuleRule(rules, import_shared.STYLUS_REGEX, config);
11
+
12
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.54.6_eslint@9.6.0_typescript@5.5.2/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 deepmerge from "deepmerge";
18
+ import { reduceConfigs } from "reduce-configs";
19
+ var PLUGIN_STYLUS_NAME = "rsbuild:stylus";
20
+ var pluginStylus = (options) => ({
21
+ name: PLUGIN_STYLUS_NAME,
22
+ setup(api) {
23
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment }) => {
24
+ const { config } = environment;
25
+ const mergedOptions = reduceConfigs({
26
+ initial: {
27
+ sourceMap: config.output.sourceMap.css
28
+ },
29
+ config: options,
30
+ mergeFn: deepmerge
68
31
  });
69
- }
70
- };
71
- }
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- pluginStylus
32
+ const rule = chain.module.rule(CHAIN_ID.RULE.STYLUS).test(/\.styl(us)?$/).merge({ sideEffects: true }).resolve.preferRelative(true).end();
33
+ const cssRule = chain.module.rules.get(CHAIN_ID.RULE.CSS);
34
+ for (const id of Object.keys(cssRule.uses.entries())) {
35
+ const loader = cssRule.uses.get(id);
36
+ const options2 = loader.get("options") ?? {};
37
+ const clonedOptions = deepmerge({}, options2);
38
+ if (id === CHAIN_ID.USE.CSS) {
39
+ clonedOptions.importLoaders = 2;
40
+ }
41
+ rule.use(id).loader(loader.get("loader")).options(clonedOptions);
42
+ }
43
+ rule.use(CHAIN_ID.USE.STYLUS).loader(__require.resolve("stylus-loader")).options(mergedOptions);
44
+ });
45
+ }
75
46
  });
47
+ export {
48
+ PLUGIN_STYLUS_NAME,
49
+ pluginStylus
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-stylus",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-beta.0",
4
4
  "description": "Stylus plugin for Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -9,37 +9,32 @@
9
9
  "directory": "packages/plugin-stylus"
10
10
  },
11
11
  "license": "MIT",
12
+ "type": "module",
12
13
  "exports": {
13
14
  ".": {
14
15
  "types": "./dist/index.d.ts",
15
- "import": "./dist/index.mjs",
16
- "default": "./dist/index.js"
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
17
18
  }
18
19
  },
19
- "main": "./dist/index.js",
20
+ "main": "./dist/index.cjs",
20
21
  "types": "./dist/index.d.ts",
21
22
  "files": [
22
23
  "dist"
23
24
  ],
24
25
  "dependencies": {
25
- "stylus": "0.59.0",
26
- "stylus-loader": "7.1.0",
27
- "@rsbuild/shared": "1.0.0"
26
+ "deepmerge": "^4.3.1",
27
+ "reduce-configs": "^1.0.0",
28
+ "stylus": "0.63.0",
29
+ "stylus-loader": "8.1.0"
28
30
  },
29
31
  "devDependencies": {
30
- "typescript": "^5.3.0",
31
- "webpack": "^5.89.0",
32
- "@rsbuild/test-helper": "1.0.0",
33
- "@rsbuild/core": "1.0.0",
34
- "@rsbuild/webpack": "1.0.0"
32
+ "typescript": "^5.5.2",
33
+ "@rsbuild/core": "1.0.1-beta.0",
34
+ "@scripts/test-helper": "1.0.1-beta.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@rsbuild/core": "^1.0.0"
38
- },
39
- "peerDependenciesMeta": {
40
- "@rsbuild/core": {
41
- "optional": true
42
- }
37
+ "@rsbuild/core": "^1.0.1-beta.0"
43
38
  },
44
39
  "publishConfig": {
45
40
  "access": "public",
package/dist/index.mjs DELETED
@@ -1,60 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.40.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
10
- import { fileURLToPath } from "url";
11
- import path from "path";
12
-
13
- // ../../scripts/require_shims.js
14
- import { createRequire } from "module";
15
- global.require = createRequire(import.meta.url);
16
-
17
- // src/index.ts
18
- import {
19
- deepmerge,
20
- STYLUS_REGEX,
21
- isUseCssSourceMap,
22
- mergeChainedOptions
23
- } from "@rsbuild/shared";
24
- function pluginStylus(options) {
25
- return {
26
- name: "rsbuild:stylus",
27
- setup(api) {
28
- const { bundlerType } = api.context;
29
- api.modifyBundlerChain(async (chain, utils) => {
30
- const config = api.getNormalizedConfig();
31
- const mergedOptions = mergeChainedOptions({
32
- defaults: {
33
- sourceMap: isUseCssSourceMap(config)
34
- },
35
- options,
36
- mergeFn: deepmerge
37
- });
38
- const rule = chain.module.rule(utils.CHAIN_ID.RULE.STYLUS).test(STYLUS_REGEX);
39
- const { applyBaseCSSRule } = await (bundlerType === "webpack" ? import("@rsbuild/webpack/plugin-css") : import("@rsbuild/core/rspack-plugin-css"));
40
- await applyBaseCSSRule({
41
- rule,
42
- config,
43
- context: api.context,
44
- utils,
45
- importLoaders: 2
46
- });
47
- rule.use(utils.CHAIN_ID.USE.STYLUS).loader(__require.resolve("stylus-loader")).options(mergedOptions);
48
- });
49
- bundlerType === "rspack" && api.modifyRspackConfig(async (rspackConfig) => {
50
- const { applyCSSModuleRule } = await import("@rsbuild/core/rspack-plugin-css");
51
- const config = api.getNormalizedConfig();
52
- const rules = rspackConfig.module?.rules;
53
- applyCSSModuleRule(rules, STYLUS_REGEX, config);
54
- });
55
- }
56
- };
57
- }
58
- export {
59
- pluginStylus
60
- };