This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+55
View File
@@ -0,0 +1,55 @@
# time-fix-plugin
[![NPM version](https://img.shields.io/npm/v/time-fix-plugin.svg?style=flat)](https://npmjs.com/package/time-fix-plugin) [![NPM downloads](https://img.shields.io/npm/dm/time-fix-plugin.svg?style=flat)](https://npmjs.com/package/time-fix-plugin) [![CircleCI](https://circleci.com/gh/egoist/time-fix-plugin/tree/master.svg?style=shield)](https://circleci.com/gh/egoist/time-fix-plugin/tree/master) [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat)](https://github.com/egoist/donate) [![chat](https://img.shields.io/badge/chat-on%20discord-7289DA.svg?style=flat)](https://chat.egoist.moe)
Why? https://github.com/webpack/watchpack/issues/25
## Install
```bash
npm i time-fix-plugin
```
This is for webpack v4 and above, for lower version please use `time-fix-plugin@1`.
## Usage
```js
// webpack.config.js
const TimeFixPlugin = require('time-fix-plugin')
module.exports = {
plugins: [
new TimeFixPlugin(),
// ...other plugins
]
}
```
## Development
```bash
# without timefix
node example/run
# with timefix
node example/run --timefix
```
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
## Author
**time-fix-plugin** © [EGOIST](https://github.com/egoist), Released under the [MIT](./LICENSE) License.<br>
Authored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/time-fix-plugin/contributors)).
> [github.com/egoist](https://github.com/egoist) · GitHub [@EGOIST](https://github.com/egoist) · Twitter [@_egoistlily](https://twitter.com/_egoistlily)
+39
View File
@@ -0,0 +1,39 @@
module.exports = class TimeFixPlugin {
constructor(watchOffset = 11000) {
this.watchOffset = watchOffset
}
apply(compiler) {
const context = this
const watch = compiler.watch
let watching
let fixed
// Modify the time for first run
compiler.watch = function () {
watching = watch.apply(this, arguments)
watching.startTime += context.watchOffset
return watching
}
// Modify the time for subsequent runs
compiler.hooks.watchRun.tap('time-fix-plugin', () => {
if (watching && !fixed) {
watching.startTime += this.watchOffset
}
})
// Reset time
compiler.hooks.done.tap('time-fix-plugin', stats => {
if (watching && !fixed) {
// webpack 5: #3
if (stats.compilation.startTime) {
stats.compilation.startTime -= this.watchOffset
} else {
stats.startTime -= this.watchOffset
}
fixed = true
}
})
}
}
+68
View File
@@ -0,0 +1,68 @@
{
"_args": [
[
"time-fix-plugin@2.0.7",
"/home/node/nuxt"
]
],
"_from": "time-fix-plugin@2.0.7",
"_id": "time-fix-plugin@2.0.7",
"_inBundle": false,
"_integrity": "sha512-uVFet1LQToeUX0rTcSiYVYVoGuBpc8gP/2jnlUzuHMHe+gux6XLsNzxLUweabMwiUj5ejhoIMsUI55nVSEa/Vw==",
"_location": "/time-fix-plugin",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "time-fix-plugin@2.0.7",
"name": "time-fix-plugin",
"escapedName": "time-fix-plugin",
"rawSpec": "2.0.7",
"saveSpec": null,
"fetchSpec": "2.0.7"
},
"_requiredBy": [
"/@nuxt/webpack"
],
"_resolved": "https://registry.npmjs.org/time-fix-plugin/-/time-fix-plugin-2.0.7.tgz",
"_spec": "2.0.7",
"_where": "/home/node/nuxt",
"author": {
"name": "egoist",
"email": "0x142857@gmail.com"
},
"bugs": {
"url": "https://github.com/egoist/time-fix-plugin/issues"
},
"description": "Fix startTime for webpack watcher",
"devDependencies": {
"eslint-config-rem": "^3.0.0",
"webpack": "^4.31.0",
"xo": "^0.18.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/egoist/time-fix-plugin#readme",
"license": "MIT",
"main": "index.js",
"name": "time-fix-plugin",
"peerDependencies": {
"webpack": ">=4.0.0"
},
"repository": {
"url": "git+https://github.com/egoist/time-fix-plugin.git",
"type": "git"
},
"scripts": {
"lint": "xo",
"test": "npm run lint && echo 'no tests!'"
},
"version": "2.0.7",
"xo": {
"extends": "rem",
"ignores": [
"example/**"
]
}
}