Skip to content

Commit e503507

Browse files
authored
Update index.js to no longer require __dirname
Based on shrhdk#76
1 parent ed06928 commit e503507

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44

55
import * as opentype from 'opentype.js';
66

7-
const DEFAULT_FONT = require('path').join(__dirname, '../fonts/ipag.ttf');
7+
// Browser bundlers might not have path or __dirname. Make DEFAULT_FONT optional
8+
let DEFAULT_FONT = '';
9+
try {
10+
DEFAULT_FONT = require('path').join(__dirname, '../fonts/ipag.ttf'); // eslint-disable-line global-require
11+
} catch (e) {
12+
DEFAULT_FONT = '';
13+
}
814

915
// Private method
1016

0 commit comments

Comments
 (0)