Skip to content

Commit

Permalink
run webpack in code-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed May 26, 2020
1 parent f9bb157 commit d1a3e6e
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 18 deletions.
5 changes: 1 addition & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,7 @@
"type": "node",
"request": "launch",
"name": "VS Code (Web)",
"runtimeExecutable": "yarn",
"runtimeArgs": [
"web"
],
"program": "${workspaceFolder}/scripts/code-web.js",
"presentation": {
"group": "0_vscode",
"order": 2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ExtensionContext, window } from 'vscode';
//import { startClient } from '../cssClient';

// this method is called when vs code is activated
export function activate(_context: ExtensionContext) {

window.showInformationMessage('cssClientBrowserMain.ts running');

//startClient(context, {});
}
Original file line number Diff line number Diff line change
@@ -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');
const path = require('path');

module.exports = withDefaults({
target: 'webworker',
context: path.join(__dirname, 'client'),
entry: {
extension: './src/browser/cssClientBrowserMain.ts',
},
output: {
filename: 'cssClientBrowserMain.js',
path: path.join(__dirname, 'client', 'dist', 'browser')
}
});
1 change: 1 addition & 0 deletions extensions/css-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"onCommand:_css.applyCodeAction"
],
"main": "./client/out/node/cssClientMain",
"browser": "./client/dist/browser/cssClientBrowserMain",
"enableProposedApi": true,
"scripts": {
"compile": "gulp compile-extension:css-language-features-client compile-extension:css-language-features-server",
Expand Down
2 changes: 1 addition & 1 deletion extensions/css-language-features/server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"

vscode-css-languageservice@^4.3.0-next.0:
[email protected]:
version "4.3.0-next.0"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-4.3.0-next.0.tgz#70ca6e192e1d7fb904867e696851b14401da9573"
integrity sha512-OwYavU+gqocK3YQi484CrGkGMMRRmzJdeNMfgAr/SssKJVJuvkLec7NbAopM42KTE6OPaqU3AFgI5AMERmIJ4A==
Expand Down
2 changes: 1 addition & 1 deletion extensions/vscode-web-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"onFileSystem:memfs",
"onDebug"
],
"main": "./out/extension",
"browser": "./out/extension",
"engines": {
"vscode": "^1.25.0"
},
Expand Down
38 changes: 26 additions & 12 deletions scripts/code-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const util = require('util');
const opn = require('opn');
const minimist = require('minimist');

const webpack = require("webpack");

const APP_ROOT = path.dirname(__dirname);
const EXTENSIONS_ROOT = path.join(APP_ROOT, 'extensions');
const WEB_MAIN = path.join(APP_ROOT, 'src', 'vs', 'code', 'browser', 'workbench', 'workbench-dev.html');
Expand Down Expand Up @@ -140,30 +142,42 @@ function handleStaticExtension(req, res, parsedUrl) {
*/
async function handleRoot(req, res) {
const extensionFolders = await util.promisify(fs.readdir)(EXTENSIONS_ROOT);
const mapExtensionFolderToExtensionPackageJSON = new Map();

const staticExtensions = [];

const webpackConfigs = [];

await Promise.all(extensionFolders.map(async extensionFolder => {
try {
const packageJSON = JSON.parse((await util.promisify(fs.readFile)(path.join(EXTENSIONS_ROOT, extensionFolder, 'package.json'))).toString());
if (packageJSON.main && packageJSON.name !== 'vscode-web-playground') {
if (packageJSON.main && !packageJSON.browser) {
return; // unsupported
}
packageJSON.extensionKind = ['web']; // enable for Web
if (packageJSON.browser) {
packageJSON.main = packageJSON.browser;
const webpackConfigPath = path.join(EXTENSIONS_ROOT, extensionFolder, 'extension-browser.webpack.config.js');
if ((await util.promisify(fs.exists)(webpackConfigPath))) {
webpackConfigs.push(require(webpackConfigPath));
packageJSON.main.replace('/out/', '/dist/');
}
}

mapExtensionFolderToExtensionPackageJSON.set(extensionFolder, packageJSON);
packageJSON.extensionKind = ['web']; // enable for Web
staticExtensions.push({
packageJSON,
extensionLocation: { scheme: SCHEME, authority: AUTHORITY, path: `/static-extension/${extensionFolder}` }
});
} catch (error) {
return null;
}
}));

const staticExtensions = [];

// Built in extensions
mapExtensionFolderToExtensionPackageJSON.forEach((packageJSON, extensionFolder) => {
staticExtensions.push({
packageJSON,
extensionLocation: { scheme: SCHEME, authority: AUTHORITY, path: `/static-extension/${extensionFolder}` }
});
webpack(webpackConfigs).watch({}, (err, stats) => {
if (err) {
console.log(err);
} else {
console.log(stats.toString());
}
});

const webConfiguration = escapeAttribute(JSON.stringify({ staticExtensions, folderUri: { scheme: 'memfs', path: `/sample-folder` }}));
Expand Down

0 comments on commit d1a3e6e

Please sign in to comment.