treeche icon indicating copy to clipboard operation
treeche copied to clipboard

Doesn't work when passing a specific file

Open thislooksfun opened this issue 2 years ago • 0 comments

When I give the program a specific file it crashes with the error

TypeError: traverse is not a function
    at replaceImportWithDummy (node_modules/treeche-core/lib/replaceImportWithDummy/mod.js:9:5)

Looking into it, the problem is that @babel/traverse and @babel/generator are both CommonJS modules that export an object with __esModule: true and a default key, which Node's native ESM importer treats as a single export default {default: <value> }, rather than splitting it into default and named imports. The fix is pretty simple, you need to either transpile into CJS with esModuleInterop: true, or you need to manually unwrap the default key when using those imports.

thislooksfun avatar Jan 06 '23 02:01 thislooksfun