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

fix: filter out illegal sourcemap items #51

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

zouhangwithsweet
Copy link
Contributor

filter ou illegal sourcemap like this

{ mappings: '' }

@antfu
Copy link
Member

antfu commented Jan 26, 2022

Can you share more context why this will happens and what is this trying to solve?

@zouhangwithsweet
Copy link
Contributor Author

zouhangwithsweet commented Jan 27, 2022

Can you share more context why this will happens and what is this trying to solve?

Yes. When I use unplugin-vue to build stylus in .vue. There is an error:

 node_modules/unplugin/dist/index.js:529:77: error: [plugin: unplugin-vue] Cannot read properties of undefined (reading 'length')
    529 │   const useArrayInterface = sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === void 0;
        ╵                                                                              ^
    at /Users/didi/Desktop/work/vue-components-lib-seed/node_modules/unplugin/dist/index.js:529:78
    at Array.find (<anonymous>)
    at combineSourcemaps (/Users/didi/Desktop/work/vue-components-lib-seed/node_modules/unplugin/dist/index.js:529:56)
    at /Users/didi/Desktop/work/vue-components-lib-seed/node_modules/unplugin/dist/index.js:624:25
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at callback (/Users/didi/Desktop/work/vue-components-lib-seed/node_modules/esbuild/lib/main.js:889:28)
    at handleRequest (/Users/didi/Desktop/work/vue-components-lib-seed/node_modules/esbuild/lib/main.js:672:30)

   node_modules/unplugin/dist/index.js:578:10: note: This error came from the "onLoad" callback registered here
    578 │           onLoad({ filter: onLoadFilter }, async (args) => {
        ╵           ~~~~~~
    at setup (/Users/didi/Desktop/work/vue-components-lib-seed/node_modules/unplugin/dist/index.js:578:11)
    at handlePlugins (/Users/didi/Desktop/work/vue-components-lib-seed/node_modules/esbuild/lib/main.js:756:23)
    at Object.buildOrServe (/Users/didi/Desktop/work/vue-components-lib-seed/node_modules/esbuild/lib/main.js:1044:7)
    at /Users/didi/Desktop/work/vue-components-lib-seed/node_modules/esbuild/lib/main.js:1895:17
    at new Promise (<anonymous>)
    at Object.build (/Users/didi/Desktop/work/vue-components-lib-seed/node_modules/esbuild/lib/main.js:1894:14)
    at build (/Users/didi/Desktop/work/vue-components-lib-seed/node_modules/esbuild/lib/main.js:1749:51)
    at run (/Users/didi/Desktop/work/vue-components-lib-seed/scripts/esbuild.ts:21:9)
    at Object.<anonymous> (/Users/didi/Desktop/work/vue-components-lib-seed/scripts/esbuild.ts:72:3)

And I found that the sourcemapList has this construction { mappings: '' }. Not every sourcemap item has the sources. So I do this change to ensure correct parameters.

@antfu antfu merged commit 6644466 into unjs:main Jan 27, 2022
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 this pull request may close these issues.

3 participants