Skip to content

Commit 397555a

Browse files
authored
Port fix for PDF saving to release (#11194)
* Fix pdf viewer so that we just ship the standalone version. (#11192) * Update changelog
1 parent d006e83 commit 397555a

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
([#11151](https://github.com/Microsoft/vscode-python/issues/11151))
101101
1. Fix CTRL+Z and Z for undo on notebooks.
102102
([#11160](https://github.com/Microsoft/vscode-python/issues/11160))
103-
103+
1. Fix saving to PDF for viewed plots.
104+
([#11157](https://github.com/Microsoft/vscode-python/issues/11157))
104105

105106
### Code Health
106107

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.

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)