microsoft / tslib

Runtime library for TypeScript helpers.
BSD Zero Clause License
1.26k stars 128 forks source link

Deprecation warning in Node 16 #152

Closed magnihansen closed 1 year ago

magnihansen commented 3 years ago

When building my Angular 12 library application i'm getting a new deprecation warning after updating to Angular 12.

My warning message (local folders): (node:9872) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at C:\g\LogicmediaAngularNpm\logicmedia-angular\library-container-project\projects\logicmedia-angular\node_modules\tslib\package.json. Update this package.json to use a subpath pattern like "./".

I'm using tslib@2.3.0 and Angular 12.1.1 I'm compiling my Angular library application using Ivy partial compilation mode.

🙁 Actual behavior My library application builds and my npm package can be published but publishing with red lines is not intended.

🙂 Expected behavior Angular not showing these red lines when building.

orta commented 3 years ago

I just triggered this on a new build, it's confusing though:

: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at C:\g\LogicmediaAngularNpm\logicmedia-angular\library-container-project\projects\logicmedia-angular\node_modules\tslib\package.json.
Update this package.json to use a subpath pattern like "./".

Use of deprecated folder mapping "./" in the "exports" field... Update this package.json to use a subpath pattern like "./"

csvn commented 3 years ago

My error message looks slightly different:

DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of 
the package at C:\...\node_modules\tslib\package.json.
Update this package.json to use a subpath pattern like "./*".

According to Node docs, it should just be replacing ./ with ./*.

    "exports": {
        ".": {
            "module": "./tslib.es6.js",
            "import": "./modules/index.js",
            "default": "./tslib.js"
        },
-       "./": "./"
+      "./*: "./*"
    }

Though I can't see the reason to export everything in the root. Mostly since there are pretty much no Javascript files to import. The only thing that might need to be exported as far as I know is package.json.

-       "./": "./"
+      "./package.json: "./package.json"
yonnic commented 3 years ago

i have the same issue on a svelte project because of some deep dependency. Would be good to have this warning gone

LittleBigBug commented 3 years ago

This is a duplicate of #134. Would be nice to see fixed

bmaland-visma commented 3 years ago

tslib now breaks in node 17:

Error loading `tslib` helper library.                                           
[!] Error: Package subpath './package.json' is not defined by "exports" in .../tslib/package.json
jakebailey commented 1 year ago

Dupe of #134, fixed back in tslib 2.4.0.