Skip to content

Not working with esbuild/vite #182

@DiscreteTom

Description

@DiscreteTom

Thanks for this cool lib!

I'm trying to use this lib in a frontend project using vite, when I build my project with esbuild I got the following error:

Illegal reassignment to import 'commonjsRequire'
file: C:/Users/xxx/node_modules/markdown-toc/lib/utils.js:10:0
 8: var utils = require('lazy-cache')(require);
 9: var fn = require;
10: require = utils;
    ^
11: 
12: /**

Looks like require is a reserved word and can't be changed, so how to solve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions