Skip to content

Commit cf8504f

Browse files
authored
Stable way to get script path for split bundles (microsoft#12191)
For #10496 Use a less hacky way to get the path to the scripts to support split bundles.
1 parent 8328187 commit cf8504f

File tree

4 files changed

+5
-42
lines changed

4 files changed

+5
-42
lines changed

src/client/datascience/notebook/renderer.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export class NotebookOutputRenderer implements VSCNotebookOutputRenderer {
1515
private _preloads: Uri[] = [];
1616
constructor() {
1717
const renderersFolder = path.join(EXTENSION_ROOT_DIR, 'out', 'datascience-ui', 'renderers');
18-
this._preloads.push(Uri.file(path.join(renderersFolder, 'pvscDummy.js')));
19-
this._preloads.push(Uri.file(path.join(renderersFolder, 'main.js')));
2018
this._preloads.push(Uri.file(path.join(renderersFolder, 'renderers.js')));
2119
}
2220

src/datascience-ui/renderers/index.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
'use strict';
55

66
// This must be on top, do not change. Required by webpack.
7-
// tslint:disable-next-line: no-var-requires no-require-imports
8-
// require('../common/main');
97
declare let __webpack_public_path__: string;
8+
const getPublicPath = () => {
9+
const currentDirname = (document.currentScript as HTMLScriptElement).src.replace(/[^/]+$/, '');
10+
return new URL(currentDirname).toString();
11+
};
1012

11-
// tslint:disable-next-line: no-any
12-
if ((window as any).__PVSC_Public_Path) {
13-
// This variable tells Webpack to this as the root path used to request webpack bundles.
14-
// tslint:disable-next-line: no-any
15-
__webpack_public_path__ = (window as any).__PVSC_Public_Path;
16-
}
13+
__webpack_public_path__ = getPublicPath();
1714
// This must be on top, do not change. Required by webpack.
1815

1916
import type { nbformat } from '@jupyterlab/coreutils';

src/datascience-ui/renderers/main.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/datascience-ui/renderers/pvscDummy.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)