Skip to content

Commit

Permalink
Add support for node esm
Browse files Browse the repository at this point in the history
  • Loading branch information
metafloor committed Jun 16, 2021
1 parent b75aba7 commit 6f681bc
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ found at the end of this document.
## Status

* Current bwip-js version is 3.0.0 (2021-04-28)
* Current bwip-js version is 3.0.1 (2021-06-16)
* Current BWIPP version is 2021-02-06
* Node.js compatibility: 0.12+
* Browser compatibility: Edge, Firefox, Chrome
Expand Down Expand Up @@ -233,7 +233,7 @@ The ESM also facilitates bundler tree shaking by providing the individual encode
Each exported encoder functions identically to `bwipjs.toCanvas()`.

The exported names are the same as the `bcid` names, with the caveat that dashes `-` are replaced with
underscores `_`. For example, if you want to import the `gs1-128` encoder, you would use:
underscores `_`. For example, to import the `gs1-128` encoder, you would use:

```javascript
import { gs1_128 } from 'bwip-js';
Expand Down
2 changes: 1 addition & 1 deletion dist/bwip-js-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/bwip-js-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -36509,7 +36509,7 @@ var PNG_CRC = (function() {
})();

var PNG_ZLIB = require('zlib');
require('stream'); // fix for https://github.com/nodejs/node/issues/37021
var __unused = require('stream'); // fix for https://github.com/nodejs/node/issues/37021

// opts is the same options object passed into the bwipjs methods.
function DrawingZlibPng(opts, callback) {
Expand Down Expand Up @@ -38769,7 +38769,7 @@ module.exports = {
request:Request, toBuffer:ToBuffer, render:Render, raw:ToRaw,
fixupOptions:FixupOptions,
loadFont:FontLib.loadFont,
BWIPJS_VERSION:'3.0.0 (2021-04-28)',
BWIPJS_VERSION:'3.0.1 (2021-06-16)',
BWIPP_VERSION:BWIPP_VERSION,
// Internals
BWIPJS:BWIPJS, STBTT:STBTT, FontLib:FontLib,
Expand Down
2 changes: 1 addition & 1 deletion dist/bwip-js-node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38877,7 +38877,7 @@ export default {
request:Request, toBuffer:ToBuffer, render:Render, raw:ToRaw,
fixupOptions : FixupOptions,
loadFont : FontLib.loadFont,
BWIPJS_VERSION : '__BWIPJS_VERS__',
BWIPJS_VERSION : '3.0.1 (2021-06-16)',
BWIPP_VERSION : BWIPP_VERSION,
// Internals
BWIPJS, STBTT, FontLib, DrawingBuiltin, DrawingZlibPng,
Expand Down
2 changes: 1 addition & 1 deletion dist/bwip-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -38607,7 +38607,7 @@ FontLib.loadFont("OCR-B", 96, 100, "AAEAAAAPAIAAAwBwRkZUTXxHn14AADmUAAAAHEdERUYA
toCanvas:ToCanvas, render:Render, raw:ToRaw,
fixupOptions:FixupOptions,
loadFont:FontLib.loadFont,
BWIPJS_VERSION:'3.0.0 (2021-04-28)',
BWIPJS_VERSION:'3.0.1 (2021-06-16)',
BWIPP_VERSION:BWIPP_VERSION,
// Internals
BWIPJS:BWIPJS, STBTT:STBTT, FontLib:FontLib,
Expand Down
2 changes: 1 addition & 1 deletion dist/bwip-js.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38706,7 +38706,7 @@ export default {
toCanvas : ToCanvas, render : Render, raw : ToRaw,
fixupOptions : FixupOptions,
loadFont : FontLib.loadFont,
BWIPJS_VERSION : '__BWIPJS_VERS__',
BWIPJS_VERSION : '3.0.1 (2021-06-16)',
BWIPP_VERSION : BWIPP_VERSION,
// Internals
BWIPJS, STBTT, FontLib, DrawingBuiltin, DrawingCanvas,
Expand Down
2 changes: 2 additions & 0 deletions examples/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ console.log('bwip-js ' + bwipjs.BWIPJS_VERSION + ' / BWIPP ' + bwipjs.BWIPP_VERS
// 100 (100%) indicates to use the font's default size.
//bwipjs.loadFont('Inconsolata', 100,
// require('fs').readFileSync(__dirname + '/fonts/Inconsolata.otf', 'binary'));
bwipjs.loadFont('Verdana', 100,
require('fs').readFileSync('c:/downloads/verdana.otf', 'binary'));

const server = http.createServer(function(req, res) {
// If the url does not begin /?bcid= then 404. Otherwise, we end up
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bwip-js",
"version": "3.0.0",
"version": "3.0.1",
"description": "JavaScript barcode generator supporting over 100 types and standards.",
"main": "./dist/bwip-js-node.js",
"browser": "./dist/bwip-js.js",
Expand All @@ -12,6 +12,7 @@
},
"electron": "./dist/bwip-js-node.js",
"node": {
"import": "./dist/bwip-js-node.mjs",
"require": "./dist/bwip-js-node.js"
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/drawing-zlibpng.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var PNG_CRC = (function() {
})();

var PNG_ZLIB = require('zlib');
require('stream'); // fix for https://github.com/nodejs/node/issues/37021
var __unused = require('stream'); // fix for https://github.com/nodejs/node/issues/37021

// opts is the same options object passed into the bwipjs methods.
function DrawingZlibPng(opts, callback) {
Expand Down

0 comments on commit 6f681bc

Please sign in to comment.