Try adding browser specific tsconfig
Trying to add this to catch dependencies we take on node typespull/129211/head
parent
b7cba9e7d4
commit
134c345351
|
@ -14,4 +14,6 @@ module.exports = withBrowserDefaults({
|
|||
entry: {
|
||||
extension: './src/extension.ts'
|
||||
}
|
||||
}, {
|
||||
configFile: 'tsconfig.browser.json'
|
||||
});
|
||||
|
|
|
@ -362,7 +362,6 @@
|
|||
"@types/highlight.js": "10.1.0",
|
||||
"@types/lodash.throttle": "^4.1.3",
|
||||
"@types/markdown-it": "0.0.2",
|
||||
"@types/node": "14.x",
|
||||
"@types/vscode-webview": "^1.57.0",
|
||||
"lodash.throttle": "^4.1.1"
|
||||
},
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { extname } from 'path';
|
||||
|
||||
import { Command } from '../commandManager';
|
||||
import { MarkdownEngine } from '../markdownEngine';
|
||||
import { TableOfContentsProvider } from '../tableOfContentsProvider';
|
||||
import { isMarkdownFile } from '../util/file';
|
||||
import { extname } from '../util/path';
|
||||
|
||||
|
||||
type UriComponents = {
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { OpenDocumentLinkCommand } from '../commands/openDocumentLink';
|
||||
import { getUriForLinkWithKnownExternalScheme, isOfScheme, Schemes } from '../util/links';
|
||||
import { dirname } from '../util/path';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
|
@ -43,7 +43,7 @@ function parseLink(
|
|||
resourceUri = vscode.Uri.joinPath(root, tempUri.path);
|
||||
}
|
||||
} else {
|
||||
const base = document.uri.with({ path: path.dirname(document.uri.fsPath) });
|
||||
const base = document.uri.with({ path: dirname(document.uri.fsPath) });
|
||||
resourceUri = vscode.Uri.joinPath(base, tempUri.path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { OpenDocumentLinkCommand, resolveLinkToMarkdownFile } from '../commands/openDocumentLink';
|
||||
|
@ -17,6 +16,7 @@ import { MarkdownPreviewConfigurationManager } from './previewConfig';
|
|||
import { MarkdownContentProvider, MarkdownContentProviderOutput } from './previewContentProvider';
|
||||
import { MarkdownEngine } from '../markdownEngine';
|
||||
import { urlToUri } from '../util/url';
|
||||
import * as path from '../util/path';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { Logger } from '../logger';
|
||||
import { MarkdownEngine } from '../markdownEngine';
|
||||
import { MarkdownContributionProvider } from '../markdownExtensions';
|
||||
import { ContentSecurityPolicyArbiter, MarkdownPreviewSecurityLevel } from '../security';
|
||||
import { basename, dirname, isAbsolute, join } from '../util/path';
|
||||
import { WebviewResourceProvider } from '../util/resources';
|
||||
import { MarkdownPreviewConfiguration, MarkdownPreviewConfigurationManager } from './previewConfig';
|
||||
|
||||
|
@ -110,7 +110,7 @@ export class MarkdownContentProvider {
|
|||
public provideFileNotFoundContent(
|
||||
resource: vscode.Uri,
|
||||
): string {
|
||||
const resourcePath = path.basename(resource.fsPath);
|
||||
const resourcePath = basename(resource.fsPath);
|
||||
const body = localize('preview.notFound', '{0} cannot be found', resourcePath);
|
||||
return `<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -136,7 +136,7 @@ export class MarkdownContentProvider {
|
|||
}
|
||||
|
||||
// Assume it must be a local file
|
||||
if (path.isAbsolute(href)) {
|
||||
if (isAbsolute(href)) {
|
||||
return resourceProvider.asWebviewUri(vscode.Uri.file(href)).toString();
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ export class MarkdownContentProvider {
|
|||
}
|
||||
|
||||
// Otherwise look relative to the markdown file
|
||||
return resourceProvider.asWebviewUri(vscode.Uri.file(path.join(path.dirname(resource.fsPath), href))).toString();
|
||||
return resourceProvider.asWebviewUri(vscode.Uri.file(join(dirname(resource.fsPath), href))).toString();
|
||||
}
|
||||
|
||||
private computeCustomStyleSheetIncludes(resourceProvider: WebviewResourceProvider, resource: vscode.Uri, config: MarkdownPreviewConfiguration): string {
|
||||
|
|
|
@ -96,7 +96,7 @@ export class MarkdownEngine {
|
|||
}
|
||||
}
|
||||
|
||||
const frontMatterPlugin = require('markdown-it-front-matter');
|
||||
const frontMatterPlugin = await import('markdown-it-front-matter');
|
||||
// Extract rules from front matter plugin and apply at a lower precedence
|
||||
let fontMatterRule: any;
|
||||
frontMatterPlugin({
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
|
||||
/// <reference path='../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>
|
||||
/// <reference types='@types/node'/>
|
||||
|
||||
declare module 'markdown-it-front-matter';
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference types='@types/node'/>
|
||||
|
||||
export { basename, dirname, extname, isAbsolute, join } from 'path';
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
declare const URL: typeof import('url').URL;
|
||||
|
||||
/**
|
||||
* Tries to convert an url into a vscode uri and returns undefined if this is not possible.
|
||||
* `url` can be absolute or relative.
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": []
|
||||
},
|
||||
"exclude": [
|
||||
"./src/test/**"
|
||||
]
|
||||
}
|
|
@ -26,11 +26,6 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.2.tgz#5d9ad19e6e6508cdd2f2596df86fd0aade598660"
|
||||
integrity sha1-XZrRnm5lCM3S8llt+G/Qqt5ZhmA=
|
||||
|
||||
"@types/node@14.x":
|
||||
version "14.14.43"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.43.tgz#26bcbb0595b305400e8ceaf9a127a7f905ae49c8"
|
||||
integrity sha512-3pwDJjp1PWacPTpH0LcfhgjvurQvrZFBrC6xxjaUEZ7ifUtT32jtjPxEMMblpqd2Mvx+k8haqQJLQxolyGN/cQ==
|
||||
|
||||
"@types/vscode-webview@^1.57.0":
|
||||
version "1.57.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/vscode-webview/-/vscode-webview-1.57.0.tgz#bad5194d45ae8d03afc1c0f67f71ff5e7a243bbf"
|
||||
|
|
|
@ -85,9 +85,13 @@ function nodePlugins(context) {
|
|||
new NLSBundlePlugin(id)
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @typedef {{
|
||||
* configFile?: string
|
||||
* }} AdditionalBrowserConfig
|
||||
*/
|
||||
|
||||
|
||||
function withBrowserDefaults(/**@type WebpackConfig*/extConfig) {
|
||||
function withBrowserDefaults(/**@type WebpackConfig*/extConfig, /** @type AdditionalBrowserConfig */ additionalOptions = {}) {
|
||||
/** @type WebpackConfig */
|
||||
let defaultConfig = {
|
||||
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
|
||||
|
@ -112,6 +116,7 @@ function withBrowserDefaults(/**@type WebpackConfig*/extConfig) {
|
|||
// * enable sources maps for end-to-end source maps
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
configFile: additionalOptions.configFile,
|
||||
compilerOptions: {
|
||||
'sourceMap': true,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue