@rsbuild/plugin-stylus 0.0.17 → 0.0.18

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.d.ts CHANGED
@@ -1,17 +1,19 @@
1
- import type { RsbuildPlugin } from '@rsbuild/core';
2
- import type { RsbuildPluginAPI } from '@rsbuild/webpack';
1
+ import { RsbuildPlugin } from '@rsbuild/core';
2
+ import { RsbuildPluginAPI } from '@rsbuild/webpack';
3
+
3
4
  type StylusOptions = {
4
- use?: string[];
5
- include?: string;
6
- import?: string;
7
- resolveURL?: boolean;
8
- lineNumbers?: boolean;
9
- hoistAtrules?: boolean;
5
+ use?: string[];
6
+ include?: string;
7
+ import?: string;
8
+ resolveURL?: boolean;
9
+ lineNumbers?: boolean;
10
+ hoistAtrules?: boolean;
10
11
  };
11
12
  type StylusLoaderOptions = {
12
- stylusOptions?: StylusOptions;
13
- sourceMap?: boolean;
13
+ stylusOptions?: StylusOptions;
14
+ sourceMap?: boolean;
14
15
  };
15
- export type PluginStylusOptions = StylusLoaderOptions;
16
- export declare function pluginStylus(options?: PluginStylusOptions): RsbuildPlugin<RsbuildPluginAPI>;
17
- export {};
16
+ type PluginStylusOptions = StylusLoaderOptions;
17
+ declare function pluginStylus(options?: PluginStylusOptions): RsbuildPlugin<RsbuildPluginAPI>;
18
+
19
+ export { PluginStylusOptions, pluginStylus };
package/dist/index.js CHANGED
@@ -26,6 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
29
31
  var src_exports = {};
30
32
  __export(src_exports, {
31
33
  pluginStylus: () => pluginStylus
@@ -48,7 +50,7 @@ function pluginStylus(options) {
48
50
  mergeFn: import_deepmerge.deepmerge
49
51
  });
50
52
  const rule = chain.module.rule(utils.CHAIN_ID.RULE.STYLUS).test(import_shared.STYLUS_REGEX);
51
- const { applyBaseCSSRule } = await (bundlerType === "webpack" ? Promise.resolve().then(() => __toESM(require("@rsbuild/webpack/plugin-css"))) : Promise.resolve().then(() => __toESM(require("@rsbuild/core/rspack-plugin-css"))));
53
+ const { applyBaseCSSRule } = await (bundlerType === "webpack" ? import("@rsbuild/webpack/plugin-css") : import("@rsbuild/core/rspack-plugin-css"));
52
54
  await applyBaseCSSRule({
53
55
  rule,
54
56
  config,
@@ -60,7 +62,7 @@ function pluginStylus(options) {
60
62
  });
61
63
  bundlerType === "rspack" && api.modifyRspackConfig(async (rspackConfig) => {
62
64
  var _a;
63
- const { applyCSSModuleRule } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/rspack-plugin-css")));
65
+ const { applyCSSModuleRule } = await import("@rsbuild/core/rspack-plugin-css");
64
66
  const config = api.getNormalizedConfig();
65
67
  const rules = (_a = rspackConfig.module) == null ? void 0 : _a.rules;
66
68
  applyCSSModuleRule(rules, import_shared.STYLUS_REGEX, config);
package/dist/index.mjs ADDED
@@ -0,0 +1,60 @@
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.39.2_typescript@5.2.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
+ STYLUS_REGEX,
20
+ isUseCssSourceMap,
21
+ mergeChainedOptions
22
+ } from "@rsbuild/shared";
23
+ import { deepmerge } from "@rsbuild/shared/deepmerge";
24
+ function pluginStylus(options) {
25
+ return {
26
+ name: "plugin-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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-stylus",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Stylus plugin for Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -12,6 +12,7 @@
12
12
  "exports": {
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.mjs",
15
16
  "default": "./dist/index.js"
16
17
  }
17
18
  },
@@ -23,17 +24,17 @@
23
24
  "dependencies": {
24
25
  "stylus": "0.59.0",
25
26
  "stylus-loader": "7.1.0",
26
- "@rsbuild/shared": "0.0.17"
27
+ "@rsbuild/shared": "0.0.18"
27
28
  },
28
29
  "devDependencies": {
29
30
  "typescript": "^5.2.2",
30
31
  "webpack": "^5.89.0",
31
- "@rsbuild/core": "0.0.17",
32
- "@rsbuild/test-helper": "0.0.17",
33
- "@rsbuild/webpack": "0.0.17"
32
+ "@rsbuild/core": "0.0.18",
33
+ "@rsbuild/test-helper": "0.0.18",
34
+ "@rsbuild/webpack": "0.0.18"
34
35
  },
35
36
  "peerDependencies": {
36
- "@rsbuild/core": "^0.0.17"
37
+ "@rsbuild/core": "^0.0.18"
37
38
  },
38
39
  "peerDependenciesMeta": {
39
40
  "@rsbuild/core": {