commit
fa0bba3705
8 changed files with 2239 additions and 0 deletions
@ -0,0 +1,2 @@ |
|||
node_modules |
|||
dist |
@ -0,0 +1,3 @@ |
|||
# Unbuild lib example |
|||
|
|||
A simple example of how to generate ESM, CJS and DTS from TypeScript using a folder as entry point. |
@ -0,0 +1,23 @@ |
|||
import { defineBuildConfig } from "unbuild"; |
|||
|
|||
export default defineBuildConfig({ |
|||
entries: [ |
|||
"src/index.ts", |
|||
{ |
|||
input: "src/plugins/", |
|||
outDir: "dist/plugins/", |
|||
format: "esm", |
|||
}, |
|||
{ |
|||
input: "src/plugins/", |
|||
outDir: "dist/plugins/", |
|||
format: "cjs", |
|||
ext: "cjs", |
|||
declaration: false, |
|||
}, |
|||
], |
|||
declaration: true, |
|||
rollup: { |
|||
emitCJS: true, |
|||
}, |
|||
}); |
@ -0,0 +1,37 @@ |
|||
{ |
|||
"name": "unbuild-example-mkdist", |
|||
"version": "1.0.0", |
|||
"type": "module", |
|||
"exports": { |
|||
".": { |
|||
"import": { |
|||
"types": "./dist/index.d.mts", |
|||
"default": "./dist/index.mjs" |
|||
}, |
|||
"require": { |
|||
"types": "./dist/index.d.cts", |
|||
"default": "./dist/index.cjs" |
|||
} |
|||
}, |
|||
"./plugins/*": { |
|||
"import": { |
|||
"types": "./dist/plugins/*.d.mts", |
|||
"default": "./dist/plugins/*.mjs" |
|||
}, |
|||
"require": { |
|||
"types": "./dist/plugins/*.d.cts", |
|||
"default": "./dist/plugins/*.cjs" |
|||
} |
|||
} |
|||
}, |
|||
"files": [ |
|||
"dist" |
|||
], |
|||
"scripts": { |
|||
"build": "unbuild", |
|||
"build:stub": "unbuild --stub" |
|||
}, |
|||
"devDependencies": { |
|||
"unbuild": "^2.0.0" |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,3 @@ |
|||
export function main(data: string): string { |
|||
return `Hello ${data}!`; |
|||
} |
@ -0,0 +1,3 @@ |
|||
export default function vitePlugin(): string { |
|||
return "Hello Vite!"; |
|||
} |
@ -0,0 +1,3 @@ |
|||
export default function webpackPlugin(): string { |
|||
return "Hello Webpack!"; |
|||
} |
Loading…
Reference in new issue