diff --git a/README.md b/README.md index d1661abe..d61e490c 100755 --- a/README.md +++ b/README.md @@ -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. diff --git a/rollup.config.js b/rollup.config.js index 8f41796a..fe2703b8 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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: [ @@ -47,5 +48,16 @@ export default [{ }, { input: './lib/index.d.ts', output: { file: './lib/bundled.d.ts', format: 'es' }, - plugins: [dts()] -}] \ No newline at end of file + 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' + ] +}])