-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly disconnect rpc client to be able to reconnect (#439)
✅ Closes: #438
- Loading branch information
1 parent
c4796b2
commit 2b72fd0
Showing
3 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { createSandbox, FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION, Sandbox } from './sandbox/Sandbox'; | ||
import { readFixture } from './sandbox/Fixture'; | ||
import { join } from 'path'; | ||
import { WEBPACK_CLI_VERSION, WEBPACK_DEV_SERVER_VERSION } from './sandbox/WebpackDevServerDriver'; | ||
|
||
describe('Webpack Node Api', () => { | ||
let sandbox: Sandbox; | ||
|
||
beforeAll(async () => { | ||
sandbox = await createSandbox(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await sandbox.reset(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await sandbox.cleanup(); | ||
}); | ||
|
||
it.each([{ webpack: '4.0.0' }, { webpack: '^4.0.0' }, { webpack: '^5.0.0-beta.16' }])( | ||
'compiles the project successfully with %p', | ||
async ({ webpack }) => { | ||
await sandbox.load([ | ||
await readFixture(join(__dirname, 'fixtures/environment/typescript-basic.fixture'), { | ||
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify( | ||
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION | ||
), | ||
TS_LOADER_VERSION: JSON.stringify('^5.0.0'), | ||
TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'), | ||
WEBPACK_VERSION: JSON.stringify(webpack), | ||
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION), | ||
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION), | ||
ASYNC: JSON.stringify(false), | ||
}), | ||
await readFixture(join(__dirname, 'fixtures/implementation/typescript-basic.fixture')), | ||
await readFixture(join(__dirname, 'fixtures/implementation/webpack-node-api.fixture')), | ||
]); | ||
|
||
const result = await sandbox.exec('node ./webpack-node-api.js'); | ||
expect(result).toContain('Compiled successfully twice.'); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// webpack-node-api.js | ||
const webpack = require("webpack"); | ||
const configuration = require("./webpack.config.js"); | ||
|
||
const builder = webpack({ ...configuration, mode: 'development' }); | ||
|
||
function run() { | ||
return new Promise((resolve, reject) => { | ||
builder.run((error, stats) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(stats); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function runAndPrint() { | ||
return run() | ||
.then((stats) => { | ||
const warnings = stats.compilation.warnings; | ||
const errors = stats.compilation.errors; | ||
|
||
if (warnings.length === 0 && errors.length === 0) { | ||
console.log('Compiled successfully.') | ||
} else { | ||
console.log('Compiled with warnings or errors.'); | ||
} | ||
}) | ||
.catch((error) => console.error(error)); | ||
} | ||
|
||
// run build twice in sequence | ||
runAndPrint() | ||
.then(() => runAndPrint()) | ||
.then(() => console.log('Compiled successfully twice.')); |