Skip to content

Commit 101f485

Browse files
authored
Fix pdf viewer so that we just ship the standalone version. (#11192)
1 parent 1b0894f commit 101f485

4 files changed

Lines changed: 12 additions & 13 deletions

File tree

build/webpack/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ exports.nodeModulesToExternalize = [
2727
'node-stream-zip',
2828
'xml2js',
2929
'vsls/vscode',
30-
'pdfkit',
30+
'pdfkit/js/pdfkit.standalone',
3131
'crypto-js',
3232
'fontkit',
3333
'linebreak',

build/webpack/webpack.extension.config.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,16 @@ const config = {
6767
externals: ['vscode', 'commonjs', ...ppaPackageList, ...existingModulesInOutDir],
6868
plugins: [
6969
...common.getDefaultPlugins('extension'),
70-
// Copy pdfkit bits after extension builds. webpack can't handle pdfkit.
71-
new FileManagerPlugin({
72-
onEnd: [
73-
{
74-
copy: [
75-
{ source: './node_modules/fontkit/*.trie', destination: './out/client/node_modules' },
76-
{ source: './node_modules/pdfkit/js/data/*.*', destination: './out/client/node_modules/data' },
77-
{ source: './node_modules/pdfkit/js/pdfkit.js', destination: './out/client/node_modules/' }
78-
]
79-
}
80-
]
70+
// Copy pdfkit after extension builds. webpack can't handle pdfkit.
71+
new removeFilesWebpackPlugin({
72+
after: { include: ['./out/client/node_modules/pdfkit/js/pdfkit.standalone.*'] }
8173
}),
74+
new copyWebpackPlugin([
75+
{
76+
from: './node_modules/pdfkit/js/pdfkit.standalone.js',
77+
to: './node_modules/pdfkit/js/pdfkit.standalone.js'
78+
}
79+
]),
8280
// ZMQ requires prebuilds to be in our node_modules directory. So recreate the ZMQ structure.
8381
// However we don't webpack to manage this, so it was part of the excluded modules. Delete it from there
8482
// so at runtime we pick up the original structure.

news/2 Fixes/11157.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix saving to PDF for viewed plots.

src/client/datascience/plotting/plotViewer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class PlotViewer extends WebViewHost<IPlotViewerMapping> implements IPlot
147147
const SVGtoPDF = require('svg-to-pdfkit');
148148
const deferred = createDeferred<void>();
149149
// tslint:disable-next-line: no-require-imports
150-
const pdfkit = require('pdfkit') as typeof import('pdfkit');
150+
const pdfkit = require('pdfkit/js/pdfkit.standalone') as typeof import('pdfkit');
151151
const doc = new pdfkit();
152152
const ws = this.fileSystem.createWriteStream(file.fsPath);
153153
traceInfo(`Writing pdf to ${file.fsPath}`);

0 commit comments

Comments
 (0)