Skip to content

Commit

Permalink
feat: add typescript build feature
Browse files Browse the repository at this point in the history
  • Loading branch information
felixranesberger committed Oct 14, 2024
1 parent 3552bbb commit c857f56
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
1 change: 1 addition & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineBuildConfig } from 'unbuild'
export default defineBuildConfig({
entries: [
'src/index',
'src/build',
],
declaration: true,
clean: true,
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "easy-ckeditor",
"type": "module",
"version": "0.0.5",
"version": "0.0.6-beta.9",
"packageManager": "pnpm@9.9.0",
"description": "Provides utility functions for easier plugin development for CKEditor 5",
"author": "Felix Ranesberger <felix.ranesberger@in2code.de>",
Expand All @@ -19,6 +19,11 @@
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"./build": {
"types": "./dist/build.d.ts",
"import": "./dist/build.mjs",
"require": "./dist/build.cjs"
}
},
"main": "./dist/index.mjs",
Expand Down Expand Up @@ -48,14 +53,14 @@
"@ckeditor/ckeditor5-engine": "^43.1.0",
"@ckeditor/ckeditor5-typing": "^43.1.0",
"@ckeditor/ckeditor5-ui": "^43.1.0",
"@ckeditor/ckeditor5-utils": "^43.1.0"
"@ckeditor/ckeditor5-utils": "^43.1.0",
"unbuild": "^2.0.0"
},
"devDependencies": {
"@antfu/eslint-config": "^3.3.2",
"@types/node": "^22.5.4",
"bumpp": "^9.5.2",
"eslint": "^9.9.1",
"typescript": "^5.5.4",
"unbuild": "^2.0.0"
"typescript": "^5.5.4"
}
}
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions src/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { build } from 'unbuild'
import type { BuildConfig } from 'unbuild'

interface Options {
plugins: {
input: `${string}.ts`
outDir: string
}[]
}

/**
* Converts your CKEditor typescript plugin files to javascript.
*/
export function buildCkEditorPlugins(args: Options): void {
(async () => {
for await (const plugin of args.plugins) {
const config: BuildConfig = {
entries: [{
builder: 'rollup',
input: plugin.input,
}],
externals: [
'@ckeditor/ckeditor5-core',
'@ckeditor/ckeditor5-engine',
'@ckeditor/ckeditor5-typing',
'@ckeditor/ckeditor5-ui',
'@ckeditor/ckeditor5-utils',
],
rollup: {
inlineDependencies: true,
output: {
dir: plugin.outDir,
},
},
clean: false,
}

await build('.', false, config)
}
})()
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"noEmit": true,
"esModuleInterop": true,
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"skipLibCheck": true
}
}

0 comments on commit c857f56

Please sign in to comment.