From 3aca5913bcf71cab75cc9458d42ca59af9030d60 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 23 Mar 2021 05:50:19 -0500 Subject: [PATCH] fix: client HMR --- packages/http/.gitignore | 1 + packages/http/build/client/index.ejs | 21 ----------------- packages/http/src/build/neutrino/virtual.js | 26 ++++++++++++++++++++- packages/http/yarn.lock | 24 +++++++++---------- 4 files changed, 38 insertions(+), 34 deletions(-) delete mode 100644 packages/http/build/client/index.ejs diff --git a/packages/http/.gitignore b/packages/http/.gitignore index 770a1d7..914d592 100644 --- a/packages/http/.gitignore +++ b/packages/http/.gitignore @@ -3,5 +3,6 @@ !/.* !src/**/*.js !/test/**/*.js +/build !/tests.js !/virtual.js diff --git a/packages/http/build/client/index.ejs b/packages/http/build/client/index.ejs deleted file mode 100644 index efd067f..0000000 --- a/packages/http/build/client/index.ejs +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - <%= htmlWebpackPlugin.options.title %> - - -
-
-
- - <%= htmlWebpackPlugin.tags.bodyTags %> - - diff --git a/packages/http/src/build/neutrino/virtual.js b/packages/http/src/build/neutrino/virtual.js index acf66d2..23a8ad3 100644 --- a/packages/http/src/build/neutrino/virtual.js +++ b/packages/http/src/build/neutrino/virtual.js @@ -1,3 +1,11 @@ +const { + basename, + dirname, + extname, + isAbsolute, + join, +} = require('path'); + const {Latus, require: R} = require('@latus/core'); const clientPlugins = require('../client-plugins'); @@ -43,7 +51,23 @@ module.exports = async (latus) => { .options({ source: source.join('\n'), }); - + if ('production' !== neutrino.config.get('mode')) { + paths.forEach((path) => { + if (isAbsolute(path)) { + return; + } + const resolved = R.resolve(path); + // Cheating for now... + const parts = resolved.split('/'); + parts.splice(parts.indexOf('packages') + 2, 0, 'src'); + let source = parts.join('/'); + source = join(dirname(source), basename(source, extname(source))); + neutrino.config.resolve.alias + .set(`${path}$`, source); + neutrino.config.module + .rule('compile').include.add(dirname(source)); + }); + } const testPaths = paths .map((path) => [path, Latus.runtimePath(`${path}/test`)]) .filter(([, path]) => !!path); diff --git a/packages/http/yarn.lock b/packages/http/yarn.lock index 9db3e23..21d7240 100644 --- a/packages/http/yarn.lock +++ b/packages/http/yarn.lock @@ -1978,9 +1978,9 @@ camelcase@^6.0.0: integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001181: - version "1.0.30001187" - resolved "http://npm.cha0sdev/caniuse-lite/-/caniuse-lite-1.0.30001187.tgz#5706942631f83baa5a0218b7dfa6ced29f845438" - integrity sha512-w7/EP1JRZ9552CyrThUnay2RkZ1DXxKe/Q2swTC4+LElLh9RRYrL1Z+27LlakB8kzY0fSmHw9mc7XYDUKAKWMA== + version "1.0.30001204" + resolved "http://npm.cha0sdev/caniuse-lite/-/caniuse-lite-1.0.30001204.tgz#256c85709a348ec4d175e847a3b515c66e79f2aa" + integrity sha512-JUdjWpcxfJ9IPamy2f5JaRDCaqJOxDzOSKtbdx4rH9VivMd1vIzoPumsJa9LoMIi4Fx2BV2KZOxWhNkBjaYivQ== chai@4.2.0: version "4.2.0" @@ -2146,9 +2146,9 @@ color-name@~1.1.4: integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== colorette@^1.2.1: - version "1.2.1" - resolved "http://npm.cha0sdev/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b" - integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw== + version "1.2.2" + resolved "http://npm.cha0sdev/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" + integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== commander@2.17.x: version "2.17.1" @@ -2739,9 +2739,9 @@ ee-first@1.1.1: integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= electron-to-chromium@^1.3.649: - version "1.3.664" - resolved "http://npm.cha0sdev/electron-to-chromium/-/electron-to-chromium-1.3.664.tgz#8fb039e2fa8ef3ab2568308464a28425d4f6e2a3" - integrity sha512-yb8LrTQXQnh9yhnaIHLk6CYugF/An50T20+X0h++hjjhVfgSp1DGoMSYycF8/aD5eiqS4QwaNhiduFvK8rifRg== + version "1.3.695" + resolved "http://npm.cha0sdev/electron-to-chromium/-/electron-to-chromium-1.3.695.tgz#955f419cf99137226180cc4cca2e59015a4e248d" + integrity sha512-lz66RliUqLHU1Ojxx1A4QUxKydjiQ79Y4dZyPobs2Dmxj5aVL2TM3KoQ2Gs7HS703Bfny+ukI3KOxwAB0xceHQ== elliptic@^6.5.3: version "6.5.4" @@ -5053,9 +5053,9 @@ node-modules-regexp@^1.0.0: integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA= node-releases@^1.1.70: - version "1.1.70" - resolved "http://npm.cha0sdev/node-releases/-/node-releases-1.1.70.tgz#66e0ed0273aa65666d7fe78febe7634875426a08" - integrity sha512-Slf2s69+2/uAD79pVVQo8uSiC34+g8GWY8UH2Qtqv34ZfhYrxpYpfzs9Js9d6O0mbDmALuxaTlplnBTnSELcrw== + version "1.1.71" + resolved "http://npm.cha0sdev/node-releases/-/node-releases-1.1.71.tgz#cb1334b179896b1c89ecfdd4b725fb7bbdfc7dbb" + integrity sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg== normalize-package-data@^2.3.2: version "2.5.0"