| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,7 +66,8 @@ | |||
| 66 | 66 | "hoge", | |
| 67 | 67 | "subsubcomain", | |
| 68 | 68 | "noselect", | |
| 69 | - "commitlint" | ||
| 69 | + "commitlint", | ||
| 70 | + "eslintcache" | ||
| 70 | 71 | ], | |
| 71 | 72 | "ignorePaths": [ | |
| 72 | 73 | "CHANGELOG.md", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,4 +20,5 @@ test/fixtures/static-config/public/assets/non-exist.txt | |||
| 20 | 20 | test/fixtures/watch-files-config/public/assets/non-exist.txt | |
| 21 | 21 | test/fixtures/reload-config/main.css | |
| 22 | 22 | test/fixtures/reload-config-2/main.css | |
| 23 | + test/fixtures/worker-config-dev-server-false/public | ||
| 23 | 24 | !/test/fixtures/static-config/public/node_modules | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1720,6 +1720,11 @@ class Server { | |||
| 1720 | 1720 | (this.compiler).compilers || [this.compiler]; | |
| 1721 | 1721 | ||
| 1722 | 1722 | for (const compiler of compilers) { | |
| 1723 | + if (compiler.options.devServer === false) { | ||
| 1724 | + // eslint-disable-next-line no-continue | ||
| 1725 | + continue; | ||
| 1726 | + } | ||
| 1727 | + | ||
| 1723 | 1728 | this.addAdditionalEntries(compiler); | |
| 1724 | 1729 | ||
| 1725 | 1730 | const webpack = compiler.webpack || require("webpack"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,7 +72,7 @@ | |||
| 72 | 72 | "serve-index": "^1.9.1", | |
| 73 | 73 | "sockjs": "^0.3.24", | |
| 74 | 74 | "spdy": "^4.0.2", | |
| 75 | - "webpack-dev-middleware": "^7.1.0", | ||
| 75 | + "webpack-dev-middleware": "^7.4.0", | ||
| 76 | 76 | "ws": "^8.18.0" | |
| 77 | 77 | }, | |
| 78 | 78 | "devDependencies": { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,6 +72,17 @@ exports[`target should work using "webworker" target: console messages 1`] = ` | |||
| 72 | 72 | ||
| 73 | 73 | exports[`target should work using "webworker" target: page errors 1`] = `[]`; | |
| 74 | 74 | ||
| 75 | + exports[`target should work using multi compiler mode with \`web\` and \`webworker\` targets with \`devServer: false\`: console messages 1`] = ` | ||
| 76 | + [ | ||
| 77 | + "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.", | ||
| 78 | + "[HMR] Waiting for update signal from WDS...", | ||
| 79 | + "Worker said: I'm working before postMessage", | ||
| 80 | + "Worker said: Message sent: message", | ||
| 81 | + ] | ||
| 82 | + `; | ||
| 83 | + | ||
| 84 | + exports[`target should work using multi compiler mode with \`web\` and \`webworker\` targets with \`devServer: false\`: page errors 1`] = `[]`; | ||
| 85 | + | ||
| 75 | 86 | exports[`target should work using multi compiler mode with \`web\` and \`webworker\` targets: console messages 1`] = ` | |
| 76 | 87 | [ | |
| 77 | 88 | "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,17 @@ | |||
| 1 | 1 | "use strict"; | |
| 2 | 2 | ||
| 3 | + const path = require("path"); | ||
| 3 | 4 | const webpack = require("webpack"); | |
| 4 | 5 | const Server = require("../../lib/Server"); | |
| 5 | 6 | const config = require("../fixtures/client-config/webpack.config"); | |
| 6 | 7 | const workerConfig = require("../fixtures/worker-config/webpack.config"); | |
| 8 | + const workerConfigDevServerFalse = require("../fixtures/worker-config-dev-server-false/webpack.config"); | ||
| 7 | 9 | const runBrowser = require("../helpers/run-browser"); | |
| 8 | 10 | const port = require("../ports-map").target; | |
| 9 | 11 | ||
| 12 | + const sortByTerm = (data, term) => | ||
| 13 | + data.sort((a, b) => (a.indexOf(term) < b.indexOf(term) ? -1 : 1)); | ||
| 14 | + | ||
| 10 | 15 | describe("target", () => { | |
| 11 | 16 | const targets = [ | |
| 12 | 17 | false, | |
@@ -35,10 +40,7 @@ describe("target", () => { | |||
| 35 | 40 | } | |
| 36 | 41 | : {}), | |
| 37 | 42 | }); | |
| 38 | - const devServerOptions = { | ||
| 39 | - port, | ||
| 40 | - }; | ||
| 41 | - const server = new Server(devServerOptions, compiler); | ||
| 43 | + const server = new Server({ port }, compiler); | ||
| 42 | 44 | ||
| 43 | 45 | await server.start(); | |
| 44 | 46 | ||
@@ -93,10 +95,58 @@ describe("target", () => { | |||
| 93 | 95 | ||
| 94 | 96 | it("should work using multi compiler mode with `web` and `webworker` targets", async () => { | |
| 95 | 97 | const compiler = webpack(workerConfig); | |
| 96 | - const devServerOptions = { | ||
| 97 | - port, | ||
| 98 | - }; | ||
| 99 | - const server = new Server(devServerOptions, compiler); | ||
| 98 | + const server = new Server({ port }, compiler); | ||
| 99 | + | ||
| 100 | + await server.start(); | ||
| 101 | + | ||
| 102 | + const { page, browser } = await runBrowser(); | ||
| 103 | + | ||
| 104 | + try { | ||
| 105 | + const pageErrors = []; | ||
| 106 | + const consoleMessages = []; | ||
| 107 | + | ||
| 108 | + page | ||
| 109 | + .on("console", (message) => { | ||
| 110 | + consoleMessages.push(message); | ||
| 111 | + }) | ||
| 112 | + .on("pageerror", (error) => { | ||
| 113 | + pageErrors.push(error); | ||
| 114 | + }); | ||
| 115 | + | ||
| 116 | + await page.goto(`http://127.0.0.1:${port}/`, { | ||
| 117 | + waitUntil: "networkidle0", | ||
| 118 | + }); | ||
| 119 | + | ||
| 120 | + expect( | ||
| 121 | + sortByTerm( | ||
| 122 | + consoleMessages.map((message) => message.text()), | ||
| 123 | + "Worker said:", | ||
| 124 | + ), | ||
| 125 | + ).toMatchSnapshot("console messages"); | ||
| 126 | + | ||
| 127 | + expect(pageErrors).toMatchSnapshot("page errors"); | ||
| 128 | + } catch (error) { | ||
| 129 | + throw error; | ||
| 130 | + } finally { | ||
| 131 | + await browser.close(); | ||
| 132 | + await server.stop(); | ||
| 133 | + } | ||
| 134 | + }); | ||
| 135 | + | ||
| 136 | + it("should work using multi compiler mode with `web` and `webworker` targets with `devServer: false`", async () => { | ||
| 137 | + const compiler = webpack(workerConfigDevServerFalse); | ||
| 138 | + const server = new Server( | ||
| 139 | + { | ||
| 140 | + port, | ||
| 141 | + static: { | ||
| 142 | + directory: path.resolve( | ||
| 143 | + __dirname, | ||
| 144 | + "../fixtures/worker-config-dev-server-false/public/", | ||
| 145 | + ), | ||
| 146 | + }, | ||
| 147 | + }, | ||
| 148 | + compiler, | ||
| 149 | + ); | ||
| 100 | 150 | ||
| 101 | 151 | await server.start(); | |
| 102 | 152 | ||
@@ -118,9 +168,12 @@ describe("target", () => { | |||
| 118 | 168 | waitUntil: "networkidle0", | |
| 119 | 169 | }); | |
| 120 | 170 | ||
| 121 | - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( | ||
| 122 | - "console messages", | ||
| 123 | - ); | ||
| 171 | + expect( | ||
| 172 | + sortByTerm( | ||
| 173 | + consoleMessages.map((message) => message.text()), | ||
| 174 | + "Worker said:", | ||
| 175 | + ), | ||
| 176 | + ).toMatchSnapshot("console messages"); | ||
| 124 | 177 | ||
| 125 | 178 | expect(pageErrors).toMatchSnapshot("page errors"); | |
| 126 | 179 | } catch (error) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,9 @@ | |||
| 1 | + "use strict"; | ||
| 2 | + | ||
| 3 | + const myWorker = new Worker("./worker-bundle.js"); | ||
| 4 | + | ||
| 5 | + myWorker.onmessage = (event) => { | ||
| 6 | + console.log(`Worker said: ${event.data}`); | ||
| 7 | + }; | ||
| 8 | + | ||
| 9 | + myWorker.postMessage("message"); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,47 @@ | |||
| 1 | + "use strict"; | ||
| 2 | + | ||
| 3 | + const path = require("path"); | ||
| 4 | + const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); | ||
| 5 | + | ||
| 6 | + module.exports = [ | ||
| 7 | + { | ||
| 8 | + name: "app", | ||
| 9 | + // dependencies: ["worker"], | ||
| 10 | + devtool: false, | ||
| 11 | + target: "web", | ||
| 12 | + entry: "./index.js", | ||
| 13 | + mode: "development", | ||
| 14 | + context: __dirname, | ||
| 15 | + stats: "none", | ||
| 16 | + output: { | ||
| 17 | + path: path.resolve(__dirname, "./dist/"), | ||
| 18 | + }, | ||
| 19 | + infrastructureLogging: { | ||
| 20 | + level: "info", | ||
| 21 | + stream: { | ||
| 22 | + write: () => {}, | ||
| 23 | + }, | ||
| 24 | + }, | ||
| 25 | + plugins: [new HTMLGeneratorPlugin()], | ||
| 26 | + }, | ||
| 27 | + { | ||
| 28 | + name: "worker", | ||
| 29 | + devtool: false, | ||
| 30 | + target: "webworker", | ||
| 31 | + entry: "./worker.js", | ||
| 32 | + mode: "development", | ||
| 33 | + context: __dirname, | ||
| 34 | + stats: "none", | ||
| 35 | + output: { | ||
| 36 | + path: path.resolve(__dirname, "public"), | ||
| 37 | + filename: "worker-bundle.js", | ||
| 38 | + }, | ||
| 39 | + infrastructureLogging: { | ||
| 40 | + level: "info", | ||
| 41 | + stream: { | ||
| 42 | + write: () => {}, | ||
| 43 | + }, | ||
| 44 | + }, | ||
| 45 | + devServer: false, | ||
| 46 | + }, | ||
| 47 | + ]; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + "use strict"; | ||
| 2 | + | ||
| 3 | + postMessage("I'm working before postMessage"); | ||
| 4 | + | ||
| 5 | + onmessage = (event) => { | ||
| 6 | + postMessage(`Message sent: ${event.data}`); | ||
| 7 | + }; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments