Notes about version 4.0 #299
Replies: 3 comments 1 reply
-
Version 4 implements a new method on the drawing interface that allows the The motivation behind this feature is the following pattern:
In previous versions, if the custom drawing object needed access to the options, for example to implement the
The new release supports an optional
|
Beta Was this translation helpful? Give feedback.
-
More complete typescript type files (.d.ts) have been requested for this project. Since I don't use typescript, it took a bit of research to understand the syntax and how to provide the linkages in Instead, the type files will be specified in the
You can read more about the typescript support for The typescript implementation was modeled after the node-js implementation. You can read about it here: https://nodejs.org/api/packages.html#conditional-exports |
Beta Was this translation helpful? Give feedback.
-
Filling in the gaps on how to deal with this new TypeScript configuration.
{
"compilerOptions": {
"customConditions": ["browser"],
}
} |
Beta Was this translation helpful? Give feedback.
-
Version 4 was released 2023-08-04. It was released as a major version bump even though it should be 100% backward compatible with version 3. The reasoning is that existing interfaces are given new functionality, specifically the named symbol exports in the ES6 modules.
The motivation behind this release is to support SVG, both as a generic
toSVG()
method and in the named symbol exports. It's the latter that caused a major change in the internal logic of the library. And with the goal to keep backward compatibility, required making the methods polymorphic.One benefit from this new architecture is that using custom drawing objects is now supported with the named symbol exports.
An example of how it works. This shows code for the browser, but similar functionality exists for node-js and react-native:
The above usage is fully tree-shakable, meaning that bundlers such as webpack and esbuild can reduce the BWIPP module down to what is required to support only qrcode.
If you don't need the bundler to do tree-shaking, you can use the generic
toSVG()
method:Beta Was this translation helpful? Give feedback.
All reactions