-
-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: extract-css should pass cacheable (#6707)
* fix: extract-css should pass cacheable * test: pass through cacheable (#6711) * test: pass cachable in css extract * test: pass cachable in css extract --------- Co-authored-by: harpsealjs <lingyucoder@gmail.com>
- Loading branch information
1 parent
fdc7685
commit 9e5732c
Showing
27 changed files
with
598 additions
and
11 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
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
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
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
2 changes: 1 addition & 1 deletion
2
...test-tools/tests/diagnosticsCases/module-build-failed/asset-module-build-failed/stats.err
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 |
---|---|---|
@@ -1 +1 @@ | ||
ERROR in ./logo.svg× Module build failed:╰─▶ × Error: Failed to loadat Object.<anonymous>.module.exports (<PROJECT_ROOT>/tests/diagnosticsCases/module-build-failed/asset-module-build-failed/my-loader.js:2:8)at LOADER_EXECUTION (<RSPACK_ROOT>/dist/loader-runner/index.js:620:23)at runSyncOrAsync (<RSPACK_ROOT>/dist/loader-runner/index.js:621:11)at <RSPACK_ROOT>/dist/loader-runner/index.js:725:9at handleResult (<RSPACK_ROOT>/dist/loader-runner/loadLoader.js:125:5)at loadLoader (<RSPACK_ROOT>/dist/loader-runner/loadLoader.js:106:16)at iterateNormalLoaders (<RSPACK_ROOT>/dist/loader-runner/index.js:714:5)at <RSPACK_ROOT>/dist/loader-runner/index.js:541:13at new Promise (<anonymous>)at runLoaders (<RSPACK_ROOT>/dist/loader-runner/index.js:516:12)help: File was processed with this loader: '<PROJECT_ROOT>/tests/diagnosticsCases/module-build-failed/asset-module-build-failed/my-loader.js' | ||
ERROR in ./logo.svg× Module build failed:╰─▶ × Error: Failed to loadat Object.<anonymous>.module.exports (<PROJECT_ROOT>/tests/diagnosticsCases/module-build-failed/asset-module-build-failed/my-loader.js:2:8)at LOADER_EXECUTION (<RSPACK_ROOT>/dist/loader-runner/index.js:626:23)at runSyncOrAsync (<RSPACK_ROOT>/dist/loader-runner/index.js:627:11)at <RSPACK_ROOT>/dist/loader-runner/index.js:731:9at handleResult (<RSPACK_ROOT>/dist/loader-runner/loadLoader.js:125:5)at loadLoader (<RSPACK_ROOT>/dist/loader-runner/loadLoader.js:106:16)at iterateNormalLoaders (<RSPACK_ROOT>/dist/loader-runner/index.js:720:5)at <RSPACK_ROOT>/dist/loader-runner/index.js:547:13at new Promise (<anonymous>)at runLoaders (<RSPACK_ROOT>/dist/loader-runner/index.js:522:12)help: File was processed with this loader: '<PROJECT_ROOT>/tests/diagnosticsCases/module-build-failed/asset-module-build-failed/my-loader.js' |
2 changes: 1 addition & 1 deletion
2
...rspack-test-tools/tests/diagnosticsCases/module-build-failed/loader-throw-error/stats.err
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 |
---|---|---|
@@ -1 +1 @@ | ||
ERROR in ./lib.js× Module build failed:╰─▶ × Error: Failed to loadat Object.<anonymous>.module.exports (<PROJECT_ROOT>/tests/diagnosticsCases/module-build-failed/loader-throw-error/my-loader.js:2:9)at LOADER_EXECUTION (<RSPACK_ROOT>/dist/loader-runner/index.js:620:23)at runSyncOrAsync (<RSPACK_ROOT>/dist/loader-runner/index.js:621:11)at <RSPACK_ROOT>/dist/loader-runner/index.js:725:9at handleResult (<RSPACK_ROOT>/dist/loader-runner/loadLoader.js:125:5)at loadLoader (<RSPACK_ROOT>/dist/loader-runner/loadLoader.js:106:16)at iterateNormalLoaders (<RSPACK_ROOT>/dist/loader-runner/index.js:714:5)at <RSPACK_ROOT>/dist/loader-runner/index.js:541:13at new Promise (<anonymous>)at runLoaders (<RSPACK_ROOT>/dist/loader-runner/index.js:516:12)help: File was processed with this loader: '<PROJECT_ROOT>/tests/diagnosticsCases/module-build-failed/loader-throw-error/my-loader.js' | ||
ERROR in ./lib.js× Module build failed:╰─▶ × Error: Failed to loadat Object.<anonymous>.module.exports (<PROJECT_ROOT>/tests/diagnosticsCases/module-build-failed/loader-throw-error/my-loader.js:2:9)at LOADER_EXECUTION (<RSPACK_ROOT>/dist/loader-runner/index.js:626:23)at runSyncOrAsync (<RSPACK_ROOT>/dist/loader-runner/index.js:627:11)at <RSPACK_ROOT>/dist/loader-runner/index.js:731:9at handleResult (<RSPACK_ROOT>/dist/loader-runner/loadLoader.js:125:5)at loadLoader (<RSPACK_ROOT>/dist/loader-runner/loadLoader.js:106:16)at iterateNormalLoaders (<RSPACK_ROOT>/dist/loader-runner/index.js:720:5)at <RSPACK_ROOT>/dist/loader-runner/index.js:547:13at new Promise (<anonymous>)at runLoaders (<RSPACK_ROOT>/dist/loader-runner/index.js:522:12)help: File was processed with this loader: '<PROJECT_ROOT>/tests/diagnosticsCases/module-build-failed/loader-throw-error/my-loader.js' |
12 changes: 12 additions & 0 deletions
12
packages/rspack-test-tools/tests/hotCases/css/css-extract/__snapshots__/web/0.snap.txt
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,12 @@ | ||
# Case css-extract: Step 0 | ||
|
||
## Changed Files | ||
|
||
|
||
## Asset Files | ||
- Bundle: bundle.js | ||
|
||
## Manifest | ||
|
||
## Update |
64 changes: 64 additions & 0 deletions
64
packages/rspack-test-tools/tests/hotCases/css/css-extract/__snapshots__/web/1.snap.txt
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,64 @@ | ||
# Case css-extract: Step 1 | ||
|
||
## Changed Files | ||
- entry.js | ||
|
||
## Asset Files | ||
- Bundle: bundle.js | ||
- Manifest: main.LAST_HASH.hot-update.json, size: 28 | ||
- Update: main.LAST_HASH.hot-update.js, size: 924 | ||
|
||
## Manifest | ||
|
||
### main.LAST_HASH.hot-update.json | ||
|
||
```json | ||
{"c":["main"],"r":[],"m":[]} | ||
``` | ||
|
||
## Update | ||
|
||
|
||
### main.LAST_HASH.hot-update.js | ||
|
||
#### Changed Modules | ||
- ./entry.js | ||
- ./index.module.css | ||
|
||
#### Changed Runtime Modules | ||
- webpack/runtime/get_full_hash | ||
|
||
#### Changed Content | ||
```js | ||
"use strict"; | ||
self["webpackHotUpdate"]('main', { | ||
"./entry.js": (function (module, __webpack_exports__, __webpack_require__) { | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */var _index_module_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index.module.css */ "./index.module.css"); | ||
|
||
module.hot.accept(); | ||
// modify | ||
/* harmony default export */ __webpack_exports__["default"] = (_index_module_css__WEBPACK_IMPORTED_MODULE_0__["default"]); | ||
|
||
|
||
}), | ||
"./index.module.css": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { | ||
__webpack_require__.r(__webpack_exports__); | ||
// extracted by css-extract-rspack-plugin | ||
/* harmony default export */ __webpack_exports__["default"] = ({"bar":"Te04splqSHRbkdUMfiwa"}); | ||
|
||
}), | ||
|
||
},function(__webpack_require__) { | ||
// webpack/runtime/get_full_hash | ||
(() => { | ||
__webpack_require__.h = function () { | ||
return "CURRENT_HASH"; | ||
}; | ||
|
||
})(); | ||
|
||
} | ||
); | ||
``` |
8 changes: 8 additions & 0 deletions
8
packages/rspack-test-tools/tests/hotCases/css/css-extract/entry.js
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,8 @@ | ||
import styles from './index.module.css' | ||
module.hot.accept(); | ||
export default styles; | ||
--- | ||
import styles from './index.module.css' | ||
module.hot.accept(); | ||
// modify | ||
export default styles; |
3 changes: 3 additions & 0 deletions
3
packages/rspack-test-tools/tests/hotCases/css/css-extract/entry2.js
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,3 @@ | ||
import styles from './index.module.css' | ||
module.hot.accept(); | ||
export default styles; |
11 changes: 11 additions & 0 deletions
11
packages/rspack-test-tools/tests/hotCases/css/css-extract/index.js
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,11 @@ | ||
const styles = require('./entry').default | ||
require('./entry2') | ||
|
||
it("css hmr", (done) => { | ||
expect(styles).toHaveProperty('foo') | ||
NEXT(require("../../update")(done, true, () => { | ||
const updatedStyles = require('./entry').default | ||
expect(updatedStyles).toHaveProperty('bar') | ||
done() | ||
})); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/rspack-test-tools/tests/hotCases/css/css-extract/index.module.css
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,3 @@ | ||
.foo { | ||
background-color: blue; | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/rspack-test-tools/tests/hotCases/css/css-extract/loader.js
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,14 @@ | ||
let i = 0; | ||
module.exports = function(content) { | ||
this.cacheable(false); | ||
i++; | ||
if (i === 1) { | ||
return content; | ||
} else { | ||
return ` | ||
.bar { | ||
color: red; | ||
} | ||
`; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
packages/rspack-test-tools/tests/hotCases/css/css-extract/rspack.config.js
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,35 @@ | ||
const rspack = require("@rspack/core"); | ||
|
||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
cache: true, | ||
mode: "development", | ||
entry: "./index", | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.module.css$/, | ||
use: [ | ||
{ | ||
loader: rspack.CssExtractRspackPlugin.loader, | ||
options: { | ||
emit: false, | ||
esModule: true, | ||
} | ||
}, | ||
"css-loader", | ||
"./loader.js" | ||
] | ||
}, | ||
] | ||
}, | ||
experiments: { | ||
css: false, | ||
}, | ||
plugins: [ | ||
new rspack.CssExtractRspackPlugin({ | ||
filename: "[name].css", | ||
runtime: false, | ||
}), | ||
] | ||
}; |
12 changes: 12 additions & 0 deletions
12
...ages/rspack-test-tools/tests/hotCases/css/recovery-cacheable/__snapshots__/web/0.snap.txt
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,12 @@ | ||
# Case recovery-cacheable: Step 0 | ||
|
||
## Changed Files | ||
|
||
|
||
## Asset Files | ||
- Bundle: bundle.js | ||
|
||
## Manifest | ||
|
||
## Update |
60 changes: 60 additions & 0 deletions
60
...ages/rspack-test-tools/tests/hotCases/css/recovery-cacheable/__snapshots__/web/2.snap.txt
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,60 @@ | ||
# Case recovery-cacheable: Step 2 | ||
|
||
## Changed Files | ||
- change.css | ||
|
||
## Asset Files | ||
- Bundle: bundle.js | ||
- Manifest: main.LAST_HASH.hot-update.json, size: 28 | ||
- Update: main.LAST_HASH.hot-update.js, size: 861 | ||
|
||
## Manifest | ||
|
||
### main.LAST_HASH.hot-update.json | ||
|
||
```json | ||
{"c":["main"],"r":[],"m":[]} | ||
``` | ||
|
||
## Update | ||
|
||
|
||
### main.LAST_HASH.hot-update.js | ||
|
||
#### Changed Modules | ||
- ./change.css?5dec | ||
|
||
#### Changed Runtime Modules | ||
- webpack/runtime/get_full_hash | ||
|
||
#### Changed Content | ||
```js | ||
"use strict"; | ||
self["webpackHotUpdate"]('main', { | ||
"./change.css?5dec": (function (module, __webpack_exports__, __webpack_require__) { | ||
__webpack_require__.r(__webpack_exports__); | ||
// extracted by css-extract-rspack-plugin | ||
|
||
if(true) { | ||
var cssReload = __webpack_require__(/*! ../../../../../rspack/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js */ "../../../../../rspack/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js")(module.id, {"locals":false}); | ||
module.hot.dispose(cssReload); | ||
module.hot.accept(undefined, function(__WEBPACK_OUTDATED_DEPENDENCIES__) { | ||
(cssReload)(__WEBPACK_OUTDATED_DEPENDENCIES__); }.bind(this)); | ||
} | ||
|
||
|
||
}), | ||
|
||
},function(__webpack_require__) { | ||
// webpack/runtime/get_full_hash | ||
(() => { | ||
__webpack_require__.h = function () { | ||
return "CURRENT_HASH"; | ||
}; | ||
|
||
})(); | ||
|
||
} | ||
); | ||
``` |
9 changes: 9 additions & 0 deletions
9
packages/rspack-test-tools/tests/hotCases/css/recovery-cacheable/change.css
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,9 @@ | ||
body { | ||
background-color: red; | ||
} | ||
--- | ||
body {} {} {@} | ||
--- | ||
body { | ||
background-color: yellow; | ||
} |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/hotCases/css/recovery-cacheable/change.js
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 @@ | ||
import './change.css' |
Oops, something went wrong.
9e5732c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
9e5732c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open