Skip to content

Commit 2cec271

Browse files
Proper output of umd (support for browserify, webpack, requirejs etc)
1 parent 1325e61 commit 2cec271

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

build.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ function monkeyPatch() {
1515
var file = id.split('/').pop();
1616
if (file === 'adler32cs.js') {
1717
code = code.replace(/this, function/g, 'jsPDF, function');
18-
code = code.replace(/typeof define/g, '0');
19-
} else if (file === 'FileSaver.js') {
20-
code = code.replace(/define !== null\) && \(define.amd != null/g, '0');
18+
code = code.replace(/require\('buffer'\)/g, '{}');
2119
}
2220
return code;
2321
}
@@ -26,8 +24,8 @@ function monkeyPatch() {
2624

2725
// Rollup removes local variables unless used within a module.
2826
// This plugin makes sure specified local variables are preserved
29-
// and kept local. This plugin won't be necessary once es2015
30-
// modules are used.
27+
// and kept local. This plugin wouldn't be necessary if es2015
28+
// modules would be used.
3129
function rawjs(opts) {
3230
opts = opts || {};
3331
return {
@@ -64,7 +62,7 @@ function bundle(paths) {
6462
})
6563
]
6664
}).then(function (bundle) {
67-
var code = bundle.generate({format: 'umd'}).code;
65+
var code = bundle.generate({format: 'umd', moduleName: 'jspdf'}).code;
6866
code = code.replace(/Permission\s+is\s+hereby\s+granted[\S\s]+?IN\s+THE\s+SOFTWARE\./, 'Licensed under the MIT License');
6967
code = code.replace(/Permission\s+is\s+hereby\s+granted[\S\s]+?IN\s+THE\s+SOFTWARE\./g, '');
7068
fs.writeFileSync(paths.debug, renew(code));

libs/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ import './deflate.js';
2626
import './html2canvas/dist/html2canvas.js';
2727
import './png_support/png.js';
2828
import './png_support/zlib.js';
29-
import './polyfill.js';
29+
import './polyfill.js';
30+
31+
export default jsPDF;

0 commit comments

Comments
 (0)