From bd988f62a2ecaf0a768db9c11c1db9e83b723122 Mon Sep 17 00:00:00 2001 From: Anthony Dresser Date: Fri, 1 Nov 2019 12:19:06 -0700 Subject: [PATCH] Add WS as a dep of notebooks (#8154) * add ws as an optional dep of noteoboks * fix method of adding ws * fix parsing for yarnrc * remove optional reps --- .../notebook/extension.webpack.config.js | 20 ++++++++++++++++--- extensions/notebook/package.json | 3 ++- extensions/notebook/yarn.lock | 12 +++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/extensions/notebook/extension.webpack.config.js b/extensions/notebook/extension.webpack.config.js index bc8fc77d3e..949cfb6824 100644 --- a/extensions/notebook/extension.webpack.config.js +++ b/extensions/notebook/extension.webpack.config.js @@ -8,13 +8,27 @@ 'use strict'; const withDefaults = require('../shared.webpack.config'); +const fs = require('fs'); +const path = require('path'); + +const externals = { + 'node-fetch': 'commonjs node-fetch' +}; + +// conditionally add ws if we are going to be running in a node environment +const yarnrcPath = path.join(__dirname, '.yarnrc'); +if (fs.existsSync(yarnrcPath)) { + const yarnrc = fs.readFileSync(yarnrcPath).toString(); + const properties = yarnrc.split(/\r?\n/).map(r => r.split(' ')); + if (properties.find(r => r[0] === 'runtime')[1] === '"node"') { + externals['ws'] = 'commonjs ws'; + } +} module.exports = withDefaults({ context: __dirname, entry: { extension: './src/extension.ts' }, - externals: { - 'node-fetch': 'commonjs node-fetch' - } + externals: externals }); diff --git a/extensions/notebook/package.json b/extensions/notebook/package.json index 0ba9eb303a..50236ac076 100644 --- a/extensions/notebook/package.json +++ b/extensions/notebook/package.json @@ -448,7 +448,8 @@ "request": "^2.88.0", "temp-write": "^3.4.0", "vscode-languageclient": "^5.3.0-next.1", - "vscode-nls": "^4.0.0" + "vscode-nls": "^4.0.0", + "ws": "^7.2.0" }, "devDependencies": { "@types/decompress": "^4.2.3", diff --git a/extensions/notebook/yarn.lock b/extensions/notebook/yarn.lock index b2a5698c2b..c589ca4fd8 100644 --- a/extensions/notebook/yarn.lock +++ b/extensions/notebook/yarn.lock @@ -339,6 +339,11 @@ assert@^1.4.1: dependencies: util "0.10.3" +async-limiter@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" + integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -2680,6 +2685,13 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= +ws@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.0.tgz#422eda8c02a4b5dba7744ba66eebbd84bcef0ec7" + integrity sha512-+SqNqFbwTm/0DC18KYzIsMTnEWpLwJsiasW/O17la4iDRRIO9uaHbvKiAS3AHgTiuuWerK/brj4O6MYZkei9xg== + dependencies: + async-limiter "^1.0.0" + xml@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"