Merge pull request #57155 from Microsoft/joh/ts-webpack

Webpack for ts extension
This commit is contained in:
Johannes Rieken 2018-08-24 17:00:11 +02:00 committed by GitHub
commit b0f63ff69d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 64 additions and 36 deletions

View file

@ -8,8 +8,6 @@
'use strict';
const withDefaults = require('../shared.webpack.config');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = withDefaults({
context: __dirname,
@ -19,11 +17,5 @@ module.exports = withDefaults({
entry: {
main: './src/main.ts',
['askpass-main']: './src/askpass-main.ts'
},
plugins: [
new CopyWebpackPlugin([
{ from: './out/*.sh', to: '[name].sh' },
{ from: './out/nls.*.json', to: '[name].json' }
])
]
}
});

View file

@ -10,6 +10,7 @@
const path = require('path');
const merge = require('merge-options');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = function withDefaults(/**@type WebpackConfig*/extConfig) {
@ -29,7 +30,10 @@ module.exports = function withDefaults(/**@type WebpackConfig*/extConfig) {
use: [{
// vscode-nls-dev loader:
// * rewrite nls-calls
loader: 'vscode-nls-dev/lib/webpack-loader'
loader: 'vscode-nls-dev/lib/webpack-loader',
options: {
base: path.join(extConfig.context, 'src')
}
}, {
// configure TypeScript loader:
// * only transpile because we have a separate compilation pipeline
@ -58,7 +62,12 @@ module.exports = function withDefaults(/**@type WebpackConfig*/extConfig) {
libraryTarget: "commonjs",
},
// yes, really source maps
devtool: 'source-map'
devtool: 'source-map',
plugins: [
new CopyWebpackPlugin([
{ from: './out/**/*', to: '.', ignore: ['*.js', '*.js.map'], flatten: true }
])
],
};
return merge(defaultConfig, extConfig);

View file

@ -1,4 +1,7 @@
build/**
src/**
test/**
tsconfig.json
tsconfig.json
node_modules/jsonc-parser/**
node_modules/semver/**

View file

@ -0,0 +1,23 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
node: {
__dirname: false,
},
resolve: {
mainFields: ['module', 'main']
},
entry: {
extension: './src/extension.ts',
}
});

View file

@ -17,13 +17,13 @@
],
"dependencies": {
"jsonc-parser": "^2.0.1",
"semver": "4.3.6",
"semver": "5.5.1",
"vscode-extension-telemetry": "0.0.18",
"vscode-nls": "^3.2.4"
},
"devDependencies": {
"@types/node": "8.0.33",
"@types/semver": "5.4.0",
"@types/semver": "^5.5.0",
"vscode": "^1.1.10"
},
"scripts": {
@ -71,7 +71,9 @@
"default": false,
"description": "%typescript.disableAutomaticTypeAcquisition%",
"scope": "window",
"tags": ["usesOnlineServices"]
"tags": [
"usesOnlineServices"
]
},
"typescript.npm": {
"type": [

View file

@ -3,7 +3,7 @@
* 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 VsCodeTelemetryReporter from 'vscode-extension-telemetry';
import { memoize } from './memoize';
@ -59,15 +59,14 @@ export default class TelemetryReporter {
@memoize
private get packageInfo(): IPackageInfo | null {
const packagePath = path.join(__dirname, '..', '..', 'package.json');
const extensionPackage = require(packagePath);
if (extensionPackage) {
const { packageJSON } = vscode.extensions.getExtension('vscode.typescript-language-features')!;
if (packageJSON) {
return {
name: extensionPackage.name,
version: extensionPackage.version,
aiKey: extensionPackage.aiKey
name: packageJSON.name,
version: packageJSON.version,
aiKey: packageJSON.aiKey
};
}
return null;
}
}
}

View file

@ -140,9 +140,9 @@ export class TypeScriptVersionProvider {
public get bundledVersion(): TypeScriptVersion {
try {
const bundledVersion = new TypeScriptVersion(
path.dirname(require.resolve('typescript/lib/tsserver.js')),
'');
const { extensionPath } = vscode.extensions.getExtension('vscode.typescript-language-features')!;
const typescriptPath = path.join(extensionPath, '../node_modules/typescript/lib');
const bundledVersion = new TypeScriptVersion(typescriptPath, '');
if (bundledVersion.isValid) {
return bundledVersion;
}

View file

@ -6,9 +6,9 @@
version "8.0.33"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.33.tgz#1126e94374014e54478092830704f6ea89df04cd"
"@types/semver@5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.4.0.tgz#f3658535af7f1f502acd6da7daf405ffeb1f7ee4"
"@types/semver@^5.5.0":
version "5.5.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.5.0.tgz#146c2a29ee7d3bae4bf2fcb274636e264c813c45"
ajv@^5.1.0:
version "5.5.2"
@ -1274,9 +1274,9 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
semver@4.3.6:
version "4.3.6"
resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da"
semver@5.5.1:
version "5.5.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477"
semver@^5.3.0, semver@^5.4.1:
version "5.5.0"

View file

@ -128,7 +128,7 @@
"vinyl": "^0.4.5",
"vinyl-fs": "^2.4.3",
"vsce": "1.33.2",
"vscode-nls-dev": "3.2.1",
"vscode-nls-dev": "3.2.2",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0",
"webpack-stream": "^5.1.1"

View file

@ -7905,9 +7905,9 @@ vscode-fsevents@0.3.8:
dependencies:
nan "^2.3.0"
vscode-nls-dev@3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/vscode-nls-dev/-/vscode-nls-dev-3.2.1.tgz#8aa9537b67d1e6e7ea4c6c4f80043c46c8a725ea"
vscode-nls-dev@3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/vscode-nls-dev/-/vscode-nls-dev-3.2.2.tgz#5855c9b3e566dd00fd6108f9c2e1bd02c925c153"
dependencies:
clone "^2.1.1"
event-stream "^3.3.4"