Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "Using WebPack" section in README about importing ably directly from static file #1792

Closed
VeskeR opened this issue Jun 14, 2024 · 0 comments · Fixed by #1808
Closed
Assignees
Labels
documentation Improvements or additions to public interface documentation (API reference or readme).

Comments

@VeskeR
Copy link
Contributor

VeskeR commented Jun 14, 2024

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.

┆Issue is synchronized with this Jira Task by Unito

@VeskeR VeskeR added the documentation Improvements or additions to public interface documentation (API reference or readme). label Jun 14, 2024
@VeskeR VeskeR changed the title Update "Using WebPack" section in README about importing directly from static file Update "Using WebPack" section in README about importing ably directly from static file Jun 14, 2024
@VeskeR VeskeR closed this as completed in 3a48da3 Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to public interface documentation (API reference or readme).
1 participant