Skip to content

Commit

Permalink
fix: deno types (#266)
Browse files Browse the repository at this point in the history
* Update rollup.config.js

* fix deno types

* Update README.md

* fix external dep warning
  • Loading branch information
mathe42 authored Apr 1, 2022
1 parent 306af43 commit ac8822b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ You can use docx-templates in Deno! Just follow the Browser guide and import the
import { createReport } from 'https://unpkg.com/docx-templates/lib/browser.js';
```

> Note that you have to set `noSandbox: true` or bring your own sandbox with the `runJs` option.
# Browser usage

You can use docx-templates in the browser (yay!). Just as when using docx-templates in Node, you need to provide the template contents as a `Buffer`-like object.
Expand Down
18 changes: 15 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import esbuild from 'rollup-plugin-esbuild'
import node from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import dts from 'rollup-plugin-dts'
import { defineConfig } from 'rollup'

export default [{
export default defineConfig([{
input: './src/browser.ts',
output: { file: './lib/browser.js', format: 'es', exports: 'named', sourcemap: true },
plugins: [
Expand Down Expand Up @@ -47,5 +48,16 @@ export default [{
}, {
input: './lib/index.d.ts',
output: { file: './lib/bundled.d.ts', format: 'es' },
plugins: [dts()]
}]
plugins: [
dts({ respectExternal: true }),
{
renderChunk(code) {
return 'type Buffer = ArrayBufferLike;\n'+ code.split('\n').slice(1).join('\n')
}
}
],
external: [
// To prevent warning. If `import ... from 'stream'` exists in bundled.d.ts this build has to be changed to remove it.
'stream'
]
}])

0 comments on commit ac8822b

Please sign in to comment.