Skip to content

Commit

Permalink
Bundle dts for Deno compatibility of browser bundle.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathe42 authored and jjhbw committed Jan 20, 2022
1 parent 2ed9585 commit 8ea51ac
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ const report = await createReport({

Check out the [Node examples folder](https://github.com/guigrpa/docx-templates/tree/master/examples/example-node).

# Deno usage
You can use docx-templates in Deno! Just follow the Browser guide and import the polyfilled docx-templates bundle, for example from unpkg:

```ts
// @deno-types="https://unpkg.com/docx-templates/lib/bundled.d.ts"
import { createReport } from 'https://unpkg.com/docx-templates/lib/browser.js';
```

# Browser usage

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"url": "git+https://github.com/guigrpa/docx-templates.git"
},
"scripts": {
"compile": "rimraf ./lib && yarn rollup && tsc",
"compile": "rimraf ./lib && tsc && yarn rollup",
"rollup": "rollup -c",
"prepack": "yarn compile",
"travis": "yarn compile && yarn test",
Expand Down Expand Up @@ -70,6 +70,7 @@
"qrcode": "^1.4.4",
"rimraf": "^3.0.2",
"rollup": "^2.56.0",
"rollup-plugin-dts": "^4.1.0",
"rollup-plugin-esbuild": "^4.5.0",
"stream-browserify": "^3.0.0",
"ts-jest": "^27.0.2",
Expand Down
9 changes: 7 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import replace from '@rollup/plugin-replace'
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'


export default {
export default [{
input: './src/browser.ts',
output: { file: './lib/browser.js', format: 'es', exports: 'named', sourcemap: true },
plugins: [
Expand Down Expand Up @@ -43,4 +44,8 @@ export default {
}
}
]
}
}, {
input: './lib/index.d.ts',
output: { file: './lib/bundled.d.ts', format: 'es' },
plugins: [dts()]
}]
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,12 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.16.0", "@babel/parser@^7.16.3", "@babel/parser@^7.7.2":
"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.7.2":
version "7.14.7"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.7.tgz#6099720c8839ca865a2637e6c85852ead0bdb595"
integrity sha512-X67Z5y+VBJuHB/RjwECp8kSl5uYi0BvRbNeWqkaJCVh+LiTPl19WBUfG627psSgp9rSf6ojuXghQM3ha6qHHdA==

"@babel/parser@^7.16.0", "@babel/parser@^7.16.3":
version "7.16.4"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.4.tgz#d5f92f57cf2c74ffe9b37981c0e72fee7311372e"
integrity sha512-6V0qdPUaiVHH3RtZeLIsc+6pDhbYzHR8ogA8w+f+Wc77DuXto19g2QUwveINoS34Uw+W8/hQDGJCx+i4n7xcng==
Expand Down Expand Up @@ -3897,6 +3902,15 @@ rimraf@^3.0.0, rimraf@^3.0.2:
dependencies:
glob "^7.1.3"

rollup-plugin-dts@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-4.1.0.tgz#63b1e7de3970bb6d50877e60df2150a3892bc49c"
integrity sha512-rriXIm3jdUiYeiAAd1Fv+x2AxK6Kq6IybB2Z/IdoAW95fb4uRUurYsEYKa8L1seedezDeJhy8cfo8FEL9aZzqg==
dependencies:
magic-string "^0.25.7"
optionalDependencies:
"@babel/code-frame" "^7.16.0"

rollup-plugin-esbuild@^4.5.0:
version "4.7.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-esbuild/-/rollup-plugin-esbuild-4.7.2.tgz#1a496a9f96257cdf5ed800e818932859232471f8"
Expand Down

0 comments on commit 8ea51ac

Please sign in to comment.