From 86b8f7838e5c9c6cb59b86b5d60f4a4eedd1a63b Mon Sep 17 00:00:00 2001 From: lorenzofox3 Date: Sat, 2 Mar 2024 15:53:40 +0100 Subject: [PATCH] feat(di): better packaging setup --- packages/di/dist/cofn-di.min.js | 1 + packages/di/package.json | 4 +++- packages/di/readme.md | 10 ++++++++++ packages/di/rollup.config.js | 5 +++++ packages/di/vite.config.js | 6 ++++++ 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 packages/di/dist/cofn-di.min.js create mode 100644 packages/di/readme.md create mode 100644 packages/di/rollup.config.js create mode 100644 packages/di/vite.config.js diff --git a/packages/di/dist/cofn-di.min.js b/packages/di/dist/cofn-di.min.js new file mode 100644 index 0000000..8eff784 --- /dev/null +++ b/packages/di/dist/cofn-di.min.js @@ -0,0 +1 @@ +const e=e=>"function"==typeof e?e:()=>e,t={},o=Symbol("registry"),r=r=>s=>{const n=e(r);return function*({$host:e,...r}){yield,e[o]=Object.assign(Object.create(e.closest("[provider]")?.[o]??t),n({$host:e,...r})),e.toggleAttribute("provider");const c=s({$host:e,...r});c.next(),yield*c}},s=r=>function*({$host:s,...n}){yield;const c=(({services:t})=>{const o=new Proxy(t,{get(r,s,n){if(!Reflect.has(t,s))throw new Error(`could not resolve injectable "${s}"`);return e(t[s])(o)}});return o})({services:s.closest("[provider]")?.[o]??t}),i=r({$host:s,services:c,...n});i.next(),yield*i};export{s as inject,r as provide}; diff --git a/packages/di/package.json b/packages/di/package.json index a69747e..caa7aed 100644 --- a/packages/di/package.json +++ b/packages/di/package.json @@ -13,7 +13,9 @@ }, "scripts": { "dev": "vite", - "test": "node test/run-ci.js" + "test": "node test/run-ci.js", + "build": "rollup -c rollup.config.js > ./dist/cofn-di.min.js", + "size": "rollup -c rollup.config.js | brotli | wc -c" }, "author": "Laurent RENARD", "devDependencies": { diff --git a/packages/di/readme.md b/packages/di/readme.md new file mode 100644 index 0000000..365b0f0 --- /dev/null +++ b/packages/di/readme.md @@ -0,0 +1,10 @@ +# DI + +Dependency injection container which leans on the DOM + +## Installation + +you can install the library with a package manager (like npm): +``npm install @cofn/di`` + +Or import it directly from a CDN diff --git a/packages/di/rollup.config.js b/packages/di/rollup.config.js new file mode 100644 index 0000000..8707094 --- /dev/null +++ b/packages/di/rollup.config.js @@ -0,0 +1,5 @@ +import terser from '@rollup/plugin-terser'; +export default { + input: 'src/index.js', + plugins: [terser()], +}; diff --git a/packages/di/vite.config.js b/packages/di/vite.config.js new file mode 100644 index 0000000..8c276bc --- /dev/null +++ b/packages/di/vite.config.js @@ -0,0 +1,6 @@ +import { defineConfig } from 'vite'; +import zoraDev from '@cofn/test-lib/vite'; + +export default defineConfig({ + plugins: [zoraDev()], +});