Skip to content

Allow globs in allowedCommonJsDependencies #18058

Closed

Description

🚀 Feature request

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Description

With NG10 I have noticed some CommonJS imports and I am now trying to hide some warnings that are save to hide. When I started adding one module name I noticed that I need to be very strict with the path, so importing dayjs/locale/de is not affected by dayjs in allowedCommonJsDependencies, so I needed to add every import twice.

Describe the solution you'd like

Allow globs in allowedCommonJsDependencies (e.g. dayjs/locale/*) or let it know when adding dayjs to allowedCommonJsDependencies that dayjs/locale/de is related to it.

// ...
            "allowedCommonJsDependencies": [
              "dayjs/locale/*", // option A
              "dayjs" // option B
            ],
// ...

Describe alternatives you've considered

Another solution would be to allow ignoring through a comment like eslint rule disabling. I noticed that this would be useful in one case where I add zone.js/dist/zone-error in my environment.ts. With a comment (e.g. @ts-ignore-import) I could ignore the warning here but would still get warnings when someone adds this line accidentally in environment.prod.ts.

// ...
/*
 * For easier debugging in development mode, you can import the following file
 * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
 */
import 'zone.js/dist/zone-error' // @ts-ignore-import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions