Skip to content

Commit 0f6cbe6

Browse files
refactor: remove subpath package for types
reference: microsoft/TypeScript#33079
1 parent d1966e0 commit 0f6cbe6

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,22 @@ npm install func-di # or other package manager
3636
Or no tool chain:
3737

3838
```html
39+
<!-- use import map to make alias for `react` -->
40+
<script type="importmap">
41+
{
42+
"imports": {
43+
"react": "https://unpkg.com/es-react"
44+
}
45+
}
46+
</script>
3947
<script type="module">
4048
import { token, inject, container } from "https://unpkg.com/func-di"; // or other CDN URL
4149
// Support ES module out of the box
4250
</script>
4351
```
4452

53+
If want to use React support in browser directly without `Node.JS` tool chain, add the following code before all script elements in your HTML. Note that `<script type="importmap">` is not currently supported in every modern browser (e.g. `FireFox`, `Safari`). You might need this tool: <https://github.com/guybedford/es-module-shims> for those browsers.
54+
4555
## Usage
4656

4757
See test cases for more details.
@@ -170,7 +180,7 @@ Using `Provide` will create a nested component. It has only one `IoCContext.Prov
170180
// Relevant dependency declarations and implementations
171181
import React from "react";
172182
import ReactDOM from "react-dom/client";
173-
import { Inject, Provide } from "func-di/react";
183+
import { Inject, Provide } from "func-di";
174184
interface CountService {
175185
count: number;
176186
}
@@ -223,8 +233,7 @@ You can also use these hooks directly inside react components to get injected de
223233

224234
```tsx
225235
// Some of the same code as above has been omitted.
226-
import { useInjection } from 'func-di/hooks';
227-
import { connectInjectionHooks } from 'func-di/react';
236+
import { useInjection, connectInjectionHooks } from 'func-di';
228237
const Component: React.FC = () => {
229238
const { count } = useInjection(countService);
230239
return (

README.zh-CN.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const dependencyB = token("ServiceB");
171171
// 相关的依赖声明与实现
172172
import React from "react";
173173
import ReactDOM from "react-dom/client";
174-
import { Inject, Provide } from "func-di/react";
174+
import { Inject, Provide } from "func-di";
175175
interface CountService {
176176
count: number;
177177
}
@@ -224,8 +224,7 @@ ReactDOM.createRoot(document.querySelector("#root")!).render(
224224

225225
```tsx
226226
// 部分与上文相同的代码已被省略。
227-
import { useInjection } from "func-di/hooks";
228-
import { connectInjectionHooks } from "func-di/react";
227+
import { useInjection, connectInjectionHooks } from 'func-di';
229228
const Component: React.FC = () => {
230229
const { count } = useInjection(countService);
231230
return (

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "A functional, immutable, type safe and simple dependency injection library inspired by angular.",
55
"main": "dist/index.js",
66
"type": "module",
7+
"sideEffects": false,
78
"scripts": {
89
"build": "ts-esmbuilder",
910
"format": "prettier --write .",

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ export * from "./consumer";
33
export * from "./container";
44
export * from "./inject";
55
export * from "./token";
6+
// TODO: Remove exports in main entry and use subpath.
7+
export * from "./hooks";
8+
export * from "./react";

0 commit comments

Comments
 (0)