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

findPostCssDependencies results in error when using autoprefixer #29

Closed
Aaronkala opened this issue Dec 22, 2022 · 3 comments
Closed

findPostCssDependencies results in error when using autoprefixer #29

Aaronkala opened this issue Dec 22, 2022 · 3 comments

Comments

@Aaronkala
Copy link

I'm getting the following error in knip@1.0.0-beta.1

/node_modules/knip/dist/util/modules.js:6
    const match = value.replace(/\\/g, '/').match(/(?<=node_modules\/)(@[^/]+\/[^/]+|[^/]+)/);
                        ^

TypeError: value.replace is not a function
    at getPackageName (/node_modules/knip/dist/util/modules.js:6:25)
    at Array.map (<anonymous>)
    at findPostCSSDependencies (/node_modules/knip/dist/plugins/postcss/index.js:13:90)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /node_modules/knip/dist/workspace-worker.js:232:34
    at async Promise.all (index 0)
    at async WorkspaceWorker.findDependenciesByPlugin (/node_modules/knip/dist/workspace-worker.js:231:45)
    at async WorkspaceWorker.findDependenciesByPlugins (/node_modules/knip/dist/workspace-worker.js:209:42)
    at async main (/node_modules/knip/dist/index.js:179:80)
    at async run (/node_modules/knip/dist/cli.js:21:46)

It seems to break when reading the package name from postcss.config.js

Our postcss.config.js contains the autoprefixer import which is a function instead of a string :)

module.exports = {
  plugins: [require('autoprefixer')],
};
@webpro
Copy link
Owner

webpro commented Dec 22, 2022

Ah yes, the postcss plugin didn't have (default) entry files yet, they're added in the latest beta :)

@Aaronkala
Copy link
Author

Awesome thanks 🙌 Great library btw! The best tool I've found for finding unused code 👍

@Aaronkala
Copy link
Author

Tested the latest release and it fixed the issue for me 🙏

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

No branches or pull requests

2 participants