Before I delve into the topic of
"allowedCommonJsDependencies"
, let me clarify that my goal is to create an npm package that can be seamlessly utilized by both Angular and non-Angular projects, without any warnings needing to be suppressed.
The npm package I have developed already includes modules in ESM format, as well as CommonJS (and even minified UMD). It offers versions in both ES6 (ES2015) and ES5 code. Below is a snippet from my package.json file:
{
"name": "@tubular/util",
"version": "3.3.0",
"description": "Miscellaneous utility functions",
"browser-es5": "dist/web5/index.js",
"browser-es6": "dist/web/index.js",
"main": "dist/es5/index.js",
"module": "dist/index.js",
"es2015": "dist/es6/index.js",
"esm2015": "dist/index.js",
"typings": "dist/index",
"sideEffects": false,
The content of dist/index.js
file is as follows:
export * from './browser-graphics-util';
export * from './browser-util';
export * from './misc-util';
export * from './string-util';
All the exported code above is written in ESM style, using import
instead of require
.
Hence, I am puzzled as to why Angular is flagging issues with the CommonJS code when it should ideally utilize the ESM code seamlessly. There should be no necessity for any warnings to be addressed.
You can access the complete source code here: https://github.com/kshetline/tubular_util