Skip to content

Double inclusion of multiple builds in a package #206

@rmja

Description

@rmja

I'm submitting a bug report

  • Library Version:
    5.0.3

Please tell us about your environment:

  • Operating System:
    Windows 11

  • Node Version:
    16.14.2

  • NPM Version:
    8.7.0

  • JSPM OR Webpack AND Version
    webpack 5.72.0

  • Browser:
    none

  • Language:
    TypeScript 4.6.4

Current behavior:
I have created a reproducing example here with a description of the problem.
In essence, it seems as if two different builds of a dependency package is included depending on whether e.g.

import { PureAbility } from "@casl/ability";

or

PLATFORM.moduleName("@casl/ability")

is used. That is probably ok, but if both are used, then only one of the two should be actually included. Currently both are included which causes strange bugs, for example when registering an instance in DI with the key PureAbility. The instance is registered with key PureAbility from one build, but is resolved with a different version of PureAbility from another build.

Expected/desired behavior:
Only one build should be resolved for any package dependency.

A workaround currently is to use NormalModuleReplacementPlugin like this in the webpack config to force one particular build:

plugins: [
    ...,
    new NormalModuleReplacementPlugin(/^@casl\/ability$/, resolve("./node_modules/@casl/ability/dist/es6m/index.mjs")),
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions