Skip to content

Commit

Permalink
Update index.js to no longer require __dirname
Browse files Browse the repository at this point in the history
Based on shrhdk#76
  • Loading branch information
incentfit authored Jan 31, 2025
1 parent ed06928 commit e503507
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

import * as opentype from 'opentype.js';

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

// Private method

Expand Down

0 comments on commit e503507

Please sign in to comment.