webpack cjs targetType compile jsPdf show error `Can't import the named export 'SVGPathData' (imported as 'SVGPathData') from default-exporting module (only default export is available)`
See original GitHub issueBug report
What is the current behavior?
i use webpack5 to compile a vue2 component, which use jspdf
.when i run webpack compile, it shows error…
when i debug the code, i found that webpack resolve buildMeta of svg-pathdata which is used in jspdf dependence canvg, to default-only
. but i look at the svg-pathdata code in github, svg-pathdata do not have a default export, it use rollup to compile the library…
If the current behavior is a bug, please provide the steps to reproduce. component code
import { jsPDF } from 'jspdf';
const pdfInstance = new jsPDF(image.width >= image.height ? 'landscape' : 'portrait', 'px', [image.width, image.height]);
webpack code
{
name: 'cjs',
target: 'web',
context: path.join(ctxDir, entry.originalName),
output: {
path: path.join(ctxDir, entry.originalName, 'dist/cjs'),
library: {
type: 'commonjs2',
},
},
}
What is the expected behavior?
it should resolve default-with-named
when webpack resolve svg-pathdata
Other relevant information: webpack version: 5.68.0 Node.js version: v14.18.2 Operating System: mac Additional tools: vscode
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
webpack - Error: Should not import the named export 'version ...
Error : Should not import the named export 'version' (imported as 'version') from default-exporting module (only default export is available soon) ...
Read more >should not import the named export 'domain ... - You.com
should not import the named export 'domain' (imported as 'domain') from default-exporting module (only default export is available soon).
Read more >Can't import the named export from non EcmaScript module
Hi My site name is stupefied-lamarr-20c8d9 On the server side of my app I have lambda functions and within those I'm using apollo-server-lambda...
Read more >jspdf - npm
Start using jspdf in your project by running `npm i jspdf`. There are 1012 other projects in the npm registry using jspdf.
Read more >html2pdf.js | Client-side HTML-to-PDF rendering using pure JS.
js converts any webpage or element into a printable PDF entirely client-side using html2canvas and jsPDF. :warning: There have been several issues reported...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@wind4gis you should put
$
in the end of regexp in yourtest
optionwith this one should be ok
i delete lerna and cli, you can checkout
test
branch, it’s a simple repo… and i found that maybe the image file loader rule cause the problemwhen i run
build
comand it works ok, runbuild:svg
it works wrong. you can checkouttest
branch, it’s so strange @vankop