Skip to content

Commit

Permalink
fix: use exports.[name] = value instead
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet committed Jun 15, 2022
1 parent ba0e4ff commit fbdeeda
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 63 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ project adheres to [Semantic Versioning](http://semver.org/).
==================
### Changed
### Added
* Added ESM support.
### Fixed
* Fixed ESM exports.

2.9.1
==================
Expand Down
64 changes: 31 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,40 +55,38 @@ function deregisterAllFonts () {
return Canvas._deregisterAllFonts()
}

module.exports = {
Canvas,
Context2d: CanvasRenderingContext2D, // Legacy/compat export
CanvasRenderingContext2D,
CanvasGradient: bindings.CanvasGradient,
CanvasPattern,
Image,
ImageData: bindings.ImageData,
PNGStream,
PDFStream,
JPEGStream,
DOMMatrix,
DOMPoint,
exports.Canvas = Canvas
exports.Context2d = CanvasRenderingContext2D // Legacy/compat export
exports.CanvasRenderingContext2D = CanvasRenderingContext2D
exports.CanvasGradient = bindings.CanvasGradient
exports.CanvasPattern = CanvasPattern
exports.Image = Image
exports.ImageData = bindings.ImageData
exports.PNGStream = PNGStream
exports.PDFStream = PDFStream
exports.JPEGStream = JPEGStream
exports.DOMMatrix = DOMMatrix
exports.DOMPoint = DOMPoint

registerFont,
deregisterAllFonts,
parseFont,
exports.registerFont = registerFont
exports.deregisterAllFonts = deregisterAllFonts
exports.parseFont = parseFont

createCanvas,
createImageData,
loadImage,
exports.createCanvas = createCanvas
exports.createImageData = createImageData
exports.loadImage = loadImage

backends: bindings.Backends,
exports.backends = bindings.Backends

/** Library version. */
version: packageJson.version,
/** Cairo version. */
cairoVersion: bindings.cairoVersion,
/** jpeglib version. */
jpegVersion: bindings.jpegVersion,
/** gif_lib version. */
gifVersion: bindings.gifVersion ? bindings.gifVersion.replace(/[^.\d]/g, '') : undefined,
/** freetype version. */
freetypeVersion: bindings.freetypeVersion,
/** rsvg version. */
rsvgVersion: bindings.rsvgVersion
}
/** Library version. */
exports.version = packageJson.version
/** Cairo version. */
exports.cairoVersion = bindings.cairoVersion
/** jpeglib version. */
exports.jpegVersion = bindings.jpegVersion
/** gif_lib version. */
exports.gifVersion = bindings.gifVersion ? bindings.gifVersion.replace(/[^.\d]/g, '') : undefined
/** freetype version. */
exports.freetypeVersion = bindings.freetypeVersion
/** rsvg version. */
exports.rsvgVersion = bindings.rsvgVersion
28 changes: 0 additions & 28 deletions index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"version": "2.9.1",
"author": "TJ Holowaychuk <tj@learnboost.com>",
"main": "index.js",
"module": "index.mjs",
"browser": "browser.js",
"contributors": [
"Nathan Rajlich <nathan@tootallnate.net>",
Expand Down

0 comments on commit fbdeeda

Please sign in to comment.