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

regression since v0.17.0 on docxtemplater : β”‚ node16 (from ESM) β”‚ πŸ•΅οΈ Named exports β”‚ #222

Closed
edi9999 opened this issue Nov 14, 2024 · 24 comments Β· Fixed by #228

Comments

@edi9999
Copy link

edi9999 commented Nov 14, 2024

Hello,

I was using version 0.15.4 without any issues now, but since upgrading to 0.17.0, I get a new issue.

This seems that this is a feature added here : https://github.com/arethetypeswrong/arethetypeswrong.github.io/pull/166/files

Here's the output I get with :

$ ./node_modules/.bin/attw --pack
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   β”‚ "docxtemplater"  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ node10            β”‚ 🟒               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ node16 (from CJS) β”‚ 🟒 (CJS)         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ node16 (from ESM) β”‚ πŸ•΅οΈ Named exports β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ bundler           β”‚ 🟒               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
./node_modules/.bin/attw --pack -f json
Full JSON { "analysis": { "packageName": "docxtemplater", "packageVersion": "3.52.0", "types": { "kind": "included" }, "buildTools": { "@arethetypeswrong/cli": "^0.17.0", "webpack": "^5.96.1" }, "entrypoints": { ".": { "subpath": ".", "resolutions": { "node10": { "name": ".", "resolutionKind": "node10", "resolution": { "fileName": "/node_modules/docxtemplater/js/docxtemplater.d.ts", "isJson": false, "isTypeScript": true, "trace": [ "======== Resolving module 'docxtemplater' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript, Declaration.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", "Found 'package.json' at '/node_modules/docxtemplater/package.json'.", "File '/node_modules/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater.d.ts' does not exist.", "'package.json' does not have a 'typesVersions' field.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field './js/docxtemplater.d.ts' that references '/node_modules/docxtemplater/js/docxtemplater.d.ts'.", "File '/node_modules/docxtemplater/js/docxtemplater.d.ts' exists - use it as a name resolution result.", "'package.json' does not have a 'peerDependencies' field.", "======== Module name 'docxtemplater' was successfully resolved to '/node_modules/docxtemplater/js/docxtemplater.d.ts' with Package ID 'docxtemplater/js/docxtemplater.d.ts@3.52.0'. ========" ] }, "implementationResolution": { "fileName": "/node_modules/docxtemplater/js/docxtemplater.js", "isJson": false, "isTypeScript": false, "trace": [ "======== Resolving module 'docxtemplater' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", "Found 'package.json' at '/node_modules/docxtemplater/package.json'.", "File '/node_modules/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater.tsx' does not exist.", "'package.json' does not have a 'typesVersions' field.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/docxtemplater/js/docxtemplater.js', target file types: TypeScript.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.tsx' does not exist.", "Directory '/node_modules/docxtemplater/js/docxtemplater.js' does not exist, skipping all lookups in it.", "File '/node_modules/docxtemplater/index.ts' does not exist.", "File '/node_modules/docxtemplater/index.tsx' does not exist.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: JavaScript, JSON.", "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", "File '/node_modules/docxtemplater/package.json' exists according to earlier cached lookups.", "File '/node_modules/docxtemplater.js' does not exist.", "File '/node_modules/docxtemplater.jsx' does not exist.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.js' exists - use it as a name resolution result.", "'package.json' does not have a 'peerDependencies' field.", "Resolution of non-relative name failed; trying with '--moduleResolution bundler' to see if project may need configuration update.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", "File '/node_modules/docxtemplater/package.json' exists according to earlier cached lookups.", "File '/node_modules/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater.tsx' does not exist.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/docxtemplater/js/docxtemplater.js', target file types: TypeScript.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.tsx' does not exist.", "Directory '/node_modules/docxtemplater/js/docxtemplater.js' does not exist, skipping all lookups in it.", "File '/node_modules/docxtemplater/index.ts' does not exist.", "File '/node_modules/docxtemplater/index.tsx' does not exist.", "======== Module name 'docxtemplater' was successfully resolved to '/node_modules/docxtemplater/js/docxtemplater.js' with Package ID 'docxtemplater/js/docxtemplater.js@3.52.0'. ========" ] }, "files": [ "/node_modules/typescript/lib/lib.d.ts", "/node_modules/docxtemplater/js/docxtemplater.d.ts" ], "visibleProblems": [] }, "node16-cjs": { "name": ".", "resolutionKind": "node16-cjs", "resolution": { "fileName": "/node_modules/docxtemplater/js/docxtemplater.d.ts", "isJson": false, "isTypeScript": true, "trace": [ "======== Resolving module 'docxtemplater' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'Node16'.", "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", "Found 'package.json' at '/node_modules/docxtemplater/package.json'.", "File '/node_modules/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater.d.ts' does not exist.", "'package.json' does not have a 'typesVersions' field.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field './js/docxtemplater.d.ts' that references '/node_modules/docxtemplater/js/docxtemplater.d.ts'.", "File '/node_modules/docxtemplater/js/docxtemplater.d.ts' exists - use it as a name resolution result.", "'package.json' does not have a 'peerDependencies' field.", "======== Module name 'docxtemplater' was successfully resolved to '/node_modules/docxtemplater/js/docxtemplater.d.ts' with Package ID 'docxtemplater/js/docxtemplater.d.ts@3.52.0'. ========" ] }, "implementationResolution": { "fileName": "/node_modules/docxtemplater/js/docxtemplater.js", "isJson": false, "isTypeScript": false, "trace": [ "======== Resolving module 'docxtemplater' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'Node16'.", "Resolving in CJS mode with conditions 'require', 'node'.", "File '/package.json' does not exist.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript, JavaScript, JSON.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", "Found 'package.json' at '/node_modules/docxtemplater/package.json'.", "File '/node_modules/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater.tsx' does not exist.", "'package.json' does not have a 'typesVersions' field.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/docxtemplater/js/docxtemplater.js', target file types: TypeScript.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.tsx' does not exist.", "Directory '/node_modules/docxtemplater/js/docxtemplater.js' does not exist, skipping all lookups in it.", "File '/node_modules/docxtemplater/index.ts' does not exist.", "File '/node_modules/docxtemplater/index.tsx' does not exist.", "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", "File '/node_modules/docxtemplater/package.json' exists according to earlier cached lookups.", "File '/node_modules/docxtemplater.js' does not exist.", "File '/node_modules/docxtemplater.jsx' does not exist.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.js' exists - use it as a name resolution result.", "'package.json' does not have a 'peerDependencies' field.", "======== Module name 'docxtemplater' was successfully resolved to '/node_modules/docxtemplater/js/docxtemplater.js' with Package ID 'docxtemplater/js/docxtemplater.js@3.52.0'. ========" ] }, "files": [ "/node_modules/typescript/lib/lib.d.ts", "/node_modules/docxtemplater/js/docxtemplater.d.ts" ], "visibleProblems": [] }, "node16-esm": { "name": ".", "resolutionKind": "node16-esm", "resolution": { "fileName": "/node_modules/docxtemplater/js/docxtemplater.d.ts", "isJson": false, "isTypeScript": true, "trace": [ "======== Resolving module 'docxtemplater' from '/index.mts'. ========", "Explicitly specified module resolution kind: 'Node16'.", "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", "File '/node_modules/docxtemplater/package.json' exists according to earlier cached lookups.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field './js/docxtemplater.d.ts' that references '/node_modules/docxtemplater/js/docxtemplater.d.ts'.", "File '/node_modules/docxtemplater/js/docxtemplater.d.ts' exists - use it as a name resolution result.", "======== Module name 'docxtemplater' was successfully resolved to '/node_modules/docxtemplater/js/docxtemplater.d.ts' with Package ID 'docxtemplater/js/docxtemplater.d.ts@3.52.0'. ========" ] }, "implementationResolution": { "fileName": "/node_modules/docxtemplater/js/docxtemplater.js", "isJson": false, "isTypeScript": false, "trace": [ "======== Resolving module 'docxtemplater' from '/index.mts'. ========", "Explicitly specified module resolution kind: 'Node16'.", "Resolving in ESM mode with conditions 'import', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript, JavaScript, JSON.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", "File '/node_modules/docxtemplater/package.json' exists according to earlier cached lookups.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/docxtemplater/js/docxtemplater.js', target file types: TypeScript.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.tsx' does not exist.", "Directory '/node_modules/docxtemplater/js/docxtemplater.js' does not exist, skipping all lookups in it.", "File name '/node_modules/docxtemplater/index.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/index.ts' does not exist.", "File '/node_modules/docxtemplater/index.tsx' does not exist.", "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", "File '/node_modules/docxtemplater/package.json' exists according to earlier cached lookups.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.js' exists - use it as a name resolution result.", "Resolution of non-relative name failed; trying with modern Node resolution features disabled to see if npm library needs configuration update.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", "File '/node_modules/docxtemplater/package.json' exists according to earlier cached lookups.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/docxtemplater/js/docxtemplater.js', target file types: TypeScript.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.tsx' does not exist.", "Directory '/node_modules/docxtemplater/js/docxtemplater.js' does not exist, skipping all lookups in it.", "File name '/node_modules/docxtemplater/index.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/index.ts' does not exist.", "File '/node_modules/docxtemplater/index.tsx' does not exist.", "======== Module name 'docxtemplater' was successfully resolved to '/node_modules/docxtemplater/js/docxtemplater.js' with Package ID 'docxtemplater/js/docxtemplater.js@3.52.0'. ========" ] }, "files": [ "/node_modules/typescript/lib/lib.d.ts", "/node_modules/docxtemplater/js/docxtemplater.d.ts" ], "visibleProblems": [ 0 ] }, "bundler": { "name": ".", "resolutionKind": "bundler", "resolution": { "fileName": "/node_modules/docxtemplater/js/docxtemplater.d.ts", "isJson": false, "isTypeScript": true, "trace": [ "======== Resolving module 'docxtemplater' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", "Resolving in CJS mode with conditions 'import', 'types'.", "File '/package.json' does not exist.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", "Found 'package.json' at '/node_modules/docxtemplater/package.json'.", "File '/node_modules/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater.d.ts' does not exist.", "'package.json' does not have a 'typesVersions' field.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field './js/docxtemplater.d.ts' that references '/node_modules/docxtemplater/js/docxtemplater.d.ts'.", "File '/node_modules/docxtemplater/js/docxtemplater.d.ts' exists - use it as a name resolution result.", "'package.json' does not have a 'peerDependencies' field.", "======== Module name 'docxtemplater' was successfully resolved to '/node_modules/docxtemplater/js/docxtemplater.d.ts' with Package ID 'docxtemplater/js/docxtemplater.d.ts@3.52.0'. ========" ] }, "implementationResolution": { "fileName": "/node_modules/docxtemplater/js/docxtemplater.js", "isJson": false, "isTypeScript": false, "trace": [ "======== Resolving module 'docxtemplater' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", "Resolving in CJS mode with conditions 'import'.", "File '/package.json' does not exist.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript, JavaScript, JSON.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", "Found 'package.json' at '/node_modules/docxtemplater/package.json'.", "File '/node_modules/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater.tsx' does not exist.", "'package.json' does not have a 'typesVersions' field.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/docxtemplater/js/docxtemplater.js', target file types: TypeScript.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.tsx' does not exist.", "Directory '/node_modules/docxtemplater/js/docxtemplater.js' does not exist, skipping all lookups in it.", "File '/node_modules/docxtemplater/index.ts' does not exist.", "File '/node_modules/docxtemplater/index.tsx' does not exist.", "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", "File '/node_modules/docxtemplater/package.json' exists according to earlier cached lookups.", "File '/node_modules/docxtemplater.js' does not exist.", "File '/node_modules/docxtemplater.jsx' does not exist.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.js' exists - use it as a name resolution result.", "'package.json' does not have a 'peerDependencies' field.", "Resolution of non-relative name failed; trying with modern Node resolution features disabled to see if npm library needs configuration update.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'docxtemplater' from 'node_modules' folder, target file types: TypeScript.", "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", "File '/node_modules/docxtemplater/package.json' exists according to earlier cached lookups.", "File '/node_modules/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater.tsx' does not exist.", "'package.json' has 'main' field 'js/docxtemplater.js' that references '/node_modules/docxtemplater/js/docxtemplater.js'.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/docxtemplater/js/docxtemplater.js', target file types: TypeScript.", "File name '/node_modules/docxtemplater/js/docxtemplater.js' has a '.js' extension - stripping it.", "File '/node_modules/docxtemplater/js/docxtemplater.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.tsx' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.ts' does not exist.", "File '/node_modules/docxtemplater/js/docxtemplater.js.tsx' does not exist.", "Directory '/node_modules/docxtemplater/js/docxtemplater.js' does not exist, skipping all lookups in it.", "File '/node_modules/docxtemplater/index.ts' does not exist.", "File '/node_modules/docxtemplater/index.tsx' does not exist.", "======== Module name 'docxtemplater' was successfully resolved to '/node_modules/docxtemplater/js/docxtemplater.js' with Package ID 'docxtemplater/js/docxtemplater.js@3.52.0'. ========" ] }, "files": [ "/node_modules/typescript/lib/lib.d.ts", "/node_modules/docxtemplater/js/docxtemplater.d.ts" ], "visibleProblems": [] } }, "hasTypes": true, "isWildcard": false } }, "programInfo": { "node10": {}, "node16": { "moduleKinds": { "/node_modules/typescript/lib/lib.d.ts": { "detectedKind": 1, "detectedReason": "no:type", "reasonFileName": "/node_modules/typescript/lib/lib.d.ts" }, "/node_modules/docxtemplater/js/docxtemplater.d.ts": { "detectedKind": 1, "detectedReason": "no:type", "reasonFileName": "/node_modules/docxtemplater/package.json" }, "/node_modules/docxtemplater/js/docxtemplater.js": { "detectedKind": 1, "detectedReason": "no:type", "reasonFileName": "/node_modules/docxtemplater/package.json" } } }, "bundler": {} }, "problems": [ { "kind": "NamedExports", "implementationFileName": "/node_modules/docxtemplater/js/docxtemplater.js", "typesFileName": "/node_modules/docxtemplater/js/docxtemplater.d.ts", "isMissingAllNamed": false, "missing": [ "prototype", "prototype" ] } ] }, "problems": { "NamedExports": [ { "kind": "NamedExports", "implementationFileName": "/node_modules/docxtemplater/js/docxtemplater.js", "typesFileName": "/node_modules/docxtemplater/js/docxtemplater.d.ts", "isMissingAllNamed": false, "missing": [ "prototype", "prototype" ] } ] } }

(The full JSON is shown above, but here is the bit that I think is relevant :

        "missing": [
          "prototype",
          "prototype"
        ]

However to be honest, I don't see what is wrong with that.

You can reproduce this with following code :

git clone https://github.com/open-xml-templating/docxtemplater.git
cd docxtemplater
npm install
# No issue here
./node_modules/.bin/attw --pack

npm install --save @arethetypeswrong/cli@0.17
# Now we have an issue !
./node_modules/.bin/attw --pack
@ljharb
Copy link
Contributor

ljharb commented Dec 3, 2024

I'm getting the same issue on a project that passed with an older version.

is there a possibility that one of the issues is when the only export from a CJS module is a constructor - whether it has quasi "named exports" or not - that it's picking up .prototype (when it shouldn't)?

@edi9999 edi9999 changed the title New issue with my library : β”‚ node16 (from ESM) β”‚ πŸ•΅οΈ Named exports β”‚ Issue since v0.17.0 running attw on docxtemplater : β”‚ node16 (from ESM) β”‚ πŸ•΅οΈ Named exports β”‚ Dec 3, 2024
@edi9999 edi9999 changed the title Issue since v0.17.0 running attw on docxtemplater : β”‚ node16 (from ESM) β”‚ πŸ•΅οΈ Named exports β”‚ regression since v0.17.0 on docxtemplater : β”‚ node16 (from ESM) β”‚ πŸ•΅οΈ Named exports β”‚ Dec 3, 2024
@edi9999
Copy link
Author

edi9999 commented Dec 3, 2024

This seems to happen since v0.16.1

@edi9999
Copy link
Author

edi9999 commented Dec 3, 2024

I think the commit that causes the issue is probably 24adb9e

However, I don't know how the library exactly works so I don't know if the fix of 24adb9e can be done while still working for our use case (docxtemplater for me, and for @ljharb )

@andrewbranch
Copy link
Collaborator

I investigated this a bit last week and discovered that it’s actually a TypeScript bug (the same root cause makes prototype show up as an auto-import in these cases). It might be best to simply filter out the string prototype (and deduplicate) here in attw in the meantime. I’m pretty swamped with TS work at the moment; would anyone be up for sending a PR?

@ljharb
Copy link
Contributor

ljharb commented Dec 3, 2024

@andrewbranch my "missing" lists include more than just prototype tho, it also includes some (but not all) of the expando properties on the constructor (that should be considered named exports).

@andrewbranch
Copy link
Collaborator

I don’t think cjs-module-lexer can recognize that though (i.e., those properties would not be available as named imports from an ESM file), so that sounds like the rule is working.

@ljharb
Copy link
Contributor

ljharb commented Dec 13, 2024

@andrewbranch fwiw, i've got another package with this error, but import() of the package in node v23.4 produces

  [Module: null prototype] {
    default: {
      assert: [Function: assert],
      get: [Function: get],
      has: [Function: has],
      set: [Function: set]
    },
    'module.exports': {
      assert: [Function: assert],
      get: [Function: get],
      has: [Function: has],
      set: [Function: set]
    }
  },
  [Symbol(async_id_symbol)]: 59,
  [Symbol(trigger_async_id_symbol)]: 6
}

which makes sense, because it's a CJS module. i'm using export = in the types as well.

is there a different tsconfig i need to make this work?

@andrewbranch
Copy link
Collaborator

@ljharb what package is that? I’ll take a look

@ljharb
Copy link
Contributor

ljharb commented Dec 13, 2024

<3 https://github.com/ljharb/internal-slot - clone and remove attw.json to reproduce

@andrewbranch
Copy link
Collaborator

The error is basically working as intended; it’s just showing a weak point of TS itself here. It looks to TS like assert, get, has, and set are available as named exports, but they’re not:

~/Developer/microsoft/eg/js
❯ node --input-type=module -e 'import { get } from "internal-slot";'
file:///Users/andrew/Developer/microsoft/eg/js/[eval1]:1
import { get } from "internal-slot";
         ^^^
SyntaxError: Named export 'get' not found. The requested module 'internal-slot' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'internal-slot';
const { get } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:146:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:229:5)
    at async ModuleLoader.eval (node:internal/modules/esm/loader:216:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:122:5)

Node.js v20.18.1

There’s no way to tell TS not to treat the properties of an export =’d object as exports. I think that’s something we’d probably change if designing with the benefit of hindsight, but the current behavior is a legacy of named imports transpiling to property accesses on a require.

@ljharb
Copy link
Contributor

ljharb commented Dec 13, 2024

If node is able to figure it out with cjs-module-lexer, why can't attw or TS?

@andrewbranch
Copy link
Collaborator

Node isn’t able to figure it out with cjs-module-lexer; that’s what I showed with the terminal snippet above. Tried again with 23.4.0 and got the same result.

@ljharb
Copy link
Contributor

ljharb commented Dec 13, 2024

It's not supposed to figure it out - it's not a module with 4 named exports, it's a single object that has 4 methods. node correctly figures out that it's only default-importable, attw is confused and thinks there should be named exports.

@andrewbranch
Copy link
Collaborator

attw is not confused. attw is telling you that TypeScript is going to interpret those 4 methods as named exports, and Node.js is not. attw doesn’t claim which interpretation is better, it’s just telling you there’s a disagreement.

@ljharb
Copy link
Contributor

ljharb commented Dec 13, 2024

ah ok, gotcha. so is there a config option that can make TS match node?

@andrewbranch
Copy link
Collaborator

Nope. I would love to say that export = properties don’t get treated like exports, but I think that would create too many false positive errors for DT libraries.

@ljharb
Copy link
Contributor

ljharb commented Dec 13, 2024

It's fine if the default stays what it is - but would it be reasonable to add a config option to TS for this?

@andrewbranch
Copy link
Collaborator

I don’t think so, because the it should be enabled under --module nodenext, it’s just that the feasibility of doing that is poor. We don’t like to make options that we can’t explain whether you should enable or not.

@ljharb
Copy link
Contributor

ljharb commented Dec 13, 2024

that's unfortunate; seems like i'll just have to live with disabling this attw rule in repos where this applies.

@ljharb
Copy link
Contributor

ljharb commented Dec 18, 2024

Got another one - a module that exports an array is reporting

        "missing": [
          "0",
          "1",
          "2",
          "length"
        ]

Code:

module.exports = require('safe-array-concat')(
    'hasIndices' in re ? 'd' : [],
    'g',
    'i',
    'm',
    'dotAll' in re ? 's' : [],
    'unicode' in re ? 'u' : [],
    'unicodeSets' in re ? 'v' : [],
    'sticky' in re ? 'y' : []
);

iow, it's statically (incorrectly) reading that array as having only 3 items, when it has anywhere from 3 to 8, and it's reporting the own properties of that array as exports, even length which is non-enumerable.

ljharb added a commit to inspect-js/available-regexp-flags that referenced this issue Dec 18, 2024
@andrewbranch
Copy link
Collaborator

There’s a condition in TS itself that avoids treating the members of array or tuple types as exports, but this function is primarily used by the language service, and so for performance reasons, it doesn’t resolve any unions or intersections to find out if a type is ultimately array- or tuple-like. What you actually have here is a union of 32 tuple types (25 because of the 5 conditional expressions) πŸ˜„ I can add the iArrayOrTupleLikeType check to attw to fix this one.

@ljharb
Copy link
Contributor

ljharb commented Dec 19, 2024

That'd be great :-D thanks! I assume attw isn't very perf-sensitive since it's a CI-time, not a dev-time, check?

@andrewbranch
Copy link
Collaborator

This is fixed in #233, but available-regexp-flags/properties still fails the check, FYI.

@ljharb
Copy link
Contributor

ljharb commented Dec 19, 2024

Thanks! I'll take it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants