ably-js
ably-js copied to clipboard
Update "Using WebPack" section in README about importing ably directly from static file
ably-js v2 uses exports
field in its package.json, so bundlers that respect this field (like webpack v5) won't be able to resolve import * as Ably from 'ably/build/ably.js'
which is currently suggested in README here. It fails with Error: Module not found: Error: Package path ./build/ably.js is not exported from package ...\node_modules\ably (see exports field in ...\node_modules\ably\package.json)
.
Instead the correct workaround is to use alias setting in webpack config like this:
// webpack.config.js
const path = require('path');
module.exports = {
module: {
rules: [
{
resolve: {
alias: {
ably: path.resolve(__dirname, 'node_modules/ably/build/ably.js'),
},
},
},
],
},
};
See internal slack thread for more context.