@canonical/react-ds-core 0.9.0-experimental.2 → 0.9.0-experimental.5

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.
Files changed (2) hide show
  1. package/README.md +28 -91
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,91 +1,28 @@
1
- # React + TypeScript + Vite
2
-
3
- This template provides a minimal setup to get React working in Vite with HMR.
4
-
5
- Currently, two official plugins are available:
6
-
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md)
8
- uses [Babel](https://babeljs.io/) for Fast Refresh
9
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc)
10
- uses [SWC](https://swc.rs/) for Fast Refresh
11
-
12
- ## Caveats
13
-
14
- ### TSConfig
15
-
16
- #### Skip library check
17
-
18
- We use [skipLibCheck](https://www.typescriptlang.org/tsconfig/#skipLibCheck) to
19
- skip type checking of declaration files. This is needed for compatibility with
20
- storybook dependencies. If this option is not enabled, the following error occurs:
21
-
22
- ```
23
- The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("storybook/internal/types")' call instead.
24
- ```
25
-
26
- Library checking is only disabled for Storybook files. This is due to
27
- Storybook dependencies using CommonJS modules alongside ECMAScript modules,
28
- which causes issues when TypeScript tries to type-check them together.
29
-
30
- Storybook files are excluded from builds in [tsconfig.build.json](tsconfig.build.json).
31
- Library type-checking is enabled for builds.
32
-
33
-
34
- ### Bun
35
-
36
- [Bun](https://bun.sh/) is being experimentally used as a package manager.
37
-
38
- ### Build tool
39
-
40
- Bun includes a [native JS bundler](https://bun.sh/docs/bundler) that can
41
- transpile Typescript.
42
-
43
- #### Downsides
44
-
45
- We are not currently considering using `bun build` for production builds for
46
- the following reasons:
47
-
48
- ##### Globstar
49
-
50
- Bun's [implementation of globstar](https://bun.sh/docs/api/glob) is non-standard.
51
- It is difficult to build arbitrarily deep filepaths, as Bun expects a globstar
52
- for each level of supported nesting. Most glob implementations treat a globstar
53
- as representing an arbitrary number of non-hidden directories. However, with
54
- Bun, matching `.ts` files in `src/ui/Button` requires the glob pattern
55
- `**/**/*.ts`, which does not match files in other levels of nesting.
56
-
57
- ##### Dist Depth
58
-
59
- Generating `dist/` output that has the correct folder structure (i.e.,
60
- `dist/ui/Button/`) is non-trivial. `bun build` generates output with folder
61
- structure starting from matching the shallowest source file. However, this is
62
- not always desired. For example, if `ui/` is inside `src/`, one must `cd` into
63
- `src` before running `bun build` to generate the appropriate folder structure.
64
- You must then set build output to `../dist` to place build results in the
65
- project root. This makes the build script unnecessarily complex.
66
-
67
- ##### Type emitting
68
-
69
- `bun build` does not generate types, so it must be accompanied by the usage of
70
- some other tool that generates type declarations.
71
-
72
- #### Upsides
73
-
74
- ##### Speed
75
-
76
- Bun builds slightly faster than the Typescript compiler.
77
-
78
- | Tool | Command | Real Time | User Time | Sys Time |
79
- | ---- | --------------------------------------------------------------------| --------- | --------- | -------- |
80
- | Bun | `bun run build:package:bun` | 0m0.648s | 0m1.498s | 0m0.117s |
81
- | Typescript | `bun run build:package:tsc && bun run build:package:copycss` | 0m0.707s | 0m1.615s | 0m0.094s |
82
-
83
- Note that the bun build must also call `tsc` to generate type declarations, and
84
- the tsc build must call the external `copyfiles` dependency to copy assets into
85
- `dist/`.
86
-
87
- ##### Non-TS bundling
88
-
89
- `bun build` copies non-TS assets (such as images, stylesheets, etc) into `dist`.
90
- `tsc` must be followed up with a manual step that copies non-TS files (currently,
91
- this is only CSS) into `dist`.
1
+ ## Canonical Design System - React Core
2
+
3
+ This package provides the core React components and utilities for Canonical's Design System.
4
+
5
+ ## Getting Started
6
+
7
+ Install the package in a React 19 project with `bun add @canonical/react-ds-core`.
8
+
9
+ Then, import components from the package and use them in your React components.
10
+ An example of a component using the `Button` component:
11
+ ```tsx
12
+ // MyComponent.tsx
13
+ import { Button } from "@canonical/react-ds-core";
14
+
15
+ function MyComponent() {
16
+ return (
17
+ <div>
18
+ <Button
19
+ appearance={"positive"}
20
+ label={"Click me"}
21
+ onClick={() => alert("hello world!")}
22
+ />
23
+ </div>
24
+ );
25
+ }
26
+
27
+ export default MyComponent;
28
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-ds-core",
3
- "version": "0.9.0-experimental.2",
3
+ "version": "0.9.0-experimental.5",
4
4
  "type": "module",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -38,7 +38,7 @@
38
38
  "test:vitest:watch": "vitest"
39
39
  },
40
40
  "dependencies": {
41
- "@canonical/storybook-config": "^0.9.0-experimental.2",
41
+ "@canonical/storybook-config": "^0.9.0-experimental.5",
42
42
  "@canonical/styles": "^0.9.0-experimental.2",
43
43
  "react": "^19.0.0",
44
44
  "react-dom": "^19.0.0"
@@ -66,5 +66,5 @@
66
66
  "vite-tsconfig-paths": "^5.1.4",
67
67
  "vitest": "^2.1.8"
68
68
  },
69
- "gitHead": "3b4b3637d6c340d1363bc89e973dadea8881f625"
69
+ "gitHead": "bc797d0c134200c372d31a8db89659caba2d6384"
70
70
  }