dn-ioc

02 · Get Started

Installation & Runtimes

dn-ioc ships as a lightweight, zero-dependency ESM package, so installing it takes one command and brings zero transitive baggage into node_modules. Grab it with whichever package manager your project already uses, or pull it straight from a CDN in the browser.

1npm install dn-ioc
1pnpm add dn-ioc
1yarn add dn-ioc
1bun add dn-ioc

Browser CDN & Import Maps

You don't need a bundler to use dn-ioc in a web page. Modern browsers can load the minified ESM build directly from a CDN:

CDNURLWhat it serves
jsDelivrhttps://cdn.jsdelivr.net/npm/dn-iocindex.min.js (minified ESM build)
unpkghttps://unpkg.com/dn-iocindex.min.js — exact same file
esm.shhttps://esm.sh/dn-iocesm.sh's own transpiled build

Without a version suffix, CDNs serve the latest release; in production, append an explicit version tag if you want to lock a page to a specific release.

Adding a <script type="importmap"> lets you keep bare 'dn-ioc' imports in your modules, so the exact same code runs with or without a bundler.

importmap.html
1<!doctype html>2<html lang="en">3  <head>4    <script type="importmap">5      {6        "imports": {7          "dn-ioc": "https://cdn.jsdelivr.net/npm/dn-ioc"8        }9      }10    </script>11  </head>12  <body>13    <script type="module">14      import { bootstrapApp, provide } from 'dn-ioc'1516      const greetingRef = provide(() => 'hello, browser')17      const app = bootstrapApp(({ inject }) => {18        document.body.textContent = inject(greetingRef)19      })2021      await app.start()22    </script>23  </body>24</html>
direct-cdn.html
1<!doctype html>2<html lang="en">3  <body>4    <script type="module">5      import { bootstrapApp, provide } from 'https://cdn.jsdelivr.net/npm/dn-ioc'67      const greetingRef = provide(() => 'hello, browser')8      const app = bootstrapApp(({ inject }) => {9        document.body.textContent = inject(greetingRef)10      })1112      await app.start()13    </script>14  </body>15</html>

ESM & TypeScript Configuration

dn-ioc is ESM-only—always load it with import rather than CommonJS require().

In TypeScript projects, set "moduleResolution": "bundler" in your tsconfig.json. Modern Vite, Bun, Next.js, Astro, and tsdown setups already use this mode by default.

tsconfig.json
1{2  "compilerOptions": {3    "target": "ES2022",4    "module": "ESNext",5    "moduleResolution": "bundler",6    "strict": true7  }8}

Because the kernel avoids process, DOM APIs, and timers, your providers stay 100% portable across Node.js, Bun, browsers, Web Workers, and edge runtimes.

AI Agent Skill

Using an AI coding agent such as Claude Code, Codex, Cursor, Antigravity, or Gemini CLI? Install the official English skill (skills/dn-ioc/SKILL.md) so the agent knows dn-ioc's exact public API, Ref vs Token rules, lifecycle invariants, and verbatim runtime errors without guessing:

1npx skills add MunMunMiao/dn-ioc
1bunx skills add MunMunMiao/dn-ioc

Prefer a single plain-text context file? Point your agent straight at /llms.txt.

Ready to wire up your first app? Flip to the Five-Minute Quickstart.