@ohos-ports/swc-plugin-auto-css-modules 0.0.0-stage → 1.6.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 fz6m
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 CHANGED
@@ -1,3 +1,90 @@
1
- # Temporary Holding Version
1
+ # swc-plugin-auto-css-modules
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Auto css modules plugin for swc.
4
+
5
+ ## HarmonyOS / openharmony port
6
+
7
+ This is the `@ohos-ports` port of `swc-plugin-auto-css-modules`. The shipped
8
+ `swc_plugin_auto_css_modules.wasm` has been rebuilt from the upstream v1.6.0
9
+ Rust source with `swc_core` 77.0.0 (rkyv-0.8) to ABI-match the
10
+ `@ohos-ports/swc-core` hosts on openharmony.
11
+
12
+ On openharmony, use `@ohos-ports/swc-core >= 1.16.2-beta.0` as the host —
13
+ the official `@swc/core` does not support openharmony. The upstream ABI
14
+ compatibility table below (`@swc/core` 1.3.106 ~ latest) applies to
15
+ non-openharmony platforms.
16
+
17
+ ```bash
18
+ pnpm i -D @ohos-ports/swc-plugin-auto-css-modules @ohos-ports/swc-core
19
+ ```
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pnpm i -D swc-plugin-auto-css-modules
25
+ ```
26
+
27
+ You should install the following versions:
28
+
29
+ |`@swc/core` version|working version|
30
+ |:-:|:-:|
31
+ | `latest` > version >= `1.3.106`|`swc-plugin-auto-css-modules@1.6.0`|
32
+ | `1.3.106` > version >= `1.3.63`|`swc-plugin-auto-css-modules@1.5.0`|
33
+ | `1.3.63` > version >= `1.3.41`|`swc-plugin-auto-css-modules@1.4.0`|
34
+ | `1.3.41` > version >= `1.3.24`|`swc-plugin-auto-css-modules@1.3.0`|
35
+
36
+ ## Usage
37
+
38
+ ```diff
39
+ // swc config
40
+ {
41
+ jsc: {
42
+ experimental: {
43
+ plugins: [
44
+ + ['swc-plugin-auto-css-modules', {}]
45
+ ],
46
+ },
47
+ }
48
+ }
49
+ ```
50
+
51
+ ### Auto css modules
52
+
53
+ This plugin will auto add the `?modules` suffix.
54
+
55
+ ```ts
56
+ import styles from './index.less'
57
+ // to
58
+ import styles from './index.less?modules'
59
+ ```
60
+
61
+ ### Lock `core-js` import
62
+
63
+ Lock `core-js` import by config `lock_core_js_pkg_path`.
64
+
65
+ ```ts
66
+ plugins: [
67
+ [
68
+ 'swc-plugin-auto-css-modules',
69
+ { lock_core_js_pkg_path: dirname(require.resolve('core-js/package.json')) },
70
+ ],
71
+ ]
72
+ ```
73
+
74
+ ```ts
75
+ import 'core-js/es/modules'
76
+ // to
77
+ import '/node_modules/**/core-js/es/modules'
78
+ ```
79
+
80
+ ## Config
81
+
82
+ See [types](./index.d.ts) file
83
+
84
+ ```ts
85
+ import type { ISwcPluginAutoCssModulesConfig } from 'swc-plugin-auto-css-modules'
86
+ ```
87
+
88
+ ## License
89
+
90
+ MIT
package/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ export interface ISwcPluginAutoCssModulesConfig {
2
+ /**
3
+ * lock core-js package root path
4
+ * @default undefined
5
+ * @example dirname(require.resolve('core-js/package.json'))
6
+ */
7
+ lock_core_js_pkg_path?: string
8
+
9
+ /**
10
+ * auto add style file suffix
11
+ * @default '?modules'
12
+ * @example '?module-mark'
13
+ */
14
+ style_file_suffix?: string
15
+ }
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@ohos-ports/swc-plugin-auto-css-modules",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.6.0-beta.0",
4
+ "description": "Auto css modules plugin for swc",
5
+ "author": "fz6m",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/umijs/swc-plugin-auto-css-modules#README",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/ohos-ports/ohos-ports.git",
11
+ "directory": "ports/swc-plugin-auto-css-modules/1.6.0"
12
+ },
13
+ "types": "index.d.ts",
14
+ "files": [
15
+ "swc_plugin_auto_css_modules.wasm",
16
+ "index.d.ts"
17
+ ],
18
+ "keywords": [
19
+ "swc-plugin",
20
+ "auto-css-modules"
21
+ ],
22
+ "main": "swc_plugin_auto_css_modules.wasm",
23
+ "scripts": {
24
+ "prepare:target": "rustup target add wasm32-wasi",
25
+ "build": "cargo build-wasi --release",
26
+ "move": "cp ./target/wasm32-wasi/release/swc_plugin_auto_css_modules.wasm .",
27
+ "test:cargo": "cargo test",
28
+ "test:node": "cd ./example && pnpm test",
29
+ "test": "pnpm test:cargo && pnpm test:node",
30
+ "prepublishOnly": "pnpm build && pnpm move && pnpm test",
31
+ "push": "npm publish --access public --registry https://registry.npmjs.com/"
32
+ },
33
+ "packageManager": "pnpm@8.15.2",
34
+ "devDependencies": {
35
+ "@types/node": "^20.11.21",
36
+ "tsx": "^4.7.1",
37
+ "zx": "^7.2.3",
38
+ "@xn-sakina/mental": "^4.2.1",
39
+ "typescript": "^5.3.3"
40
+ }
41
+ }
Binary file