Skip to content

Commit

Permalink
refactor!: migrate to webpack 5 native cache
Browse files Browse the repository at this point in the history
BREAKING CHANGE: api `.webpackUtils` has been removed

Signed-off-by: Chawye Hsu <[email protected]>
  • Loading branch information
chawyehsu committed Jan 19, 2025
1 parent 51b8774 commit 7551f99
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 93 deletions.
1 change: 0 additions & 1 deletion packages/@alterjs/saber/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@babel/parser": "^7.26.5",
"@babel/traverse": "^7.26.5",
"cac": "^6.7.14",
"cache-loader": "4.1.0",
"chokidar": "^3.5.3",
"css-loader": "5.2.7",
"devalue": "^2.0.0",
Expand Down
34 changes: 0 additions & 34 deletions packages/@alterjs/saber/src/WebpackUtils.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/@alterjs/saber/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import configLoader from './utils/configLoader'
import resolvePackage from './utils/resolvePackage'
import builtinPlugins from './plugins'
import { Compiler } from './Compiler'
import { WebpackUtils } from './WebpackUtils'
import { hooks } from './hooks'
import { VueRenderer } from './vue-renderer'
import type { ValidatedSaberConfig } from './utils/validateConfig'
Expand Down Expand Up @@ -237,7 +236,6 @@ export class Saber {
config: ValidatedSaberConfig
pages: Pages
browserApi: BrowserApi
webpackUtils: WebpackUtils
log: Log
colors: typeof colors
utils: any
Expand Down Expand Up @@ -269,7 +267,6 @@ export class Saber {
this.initialConfig = config
this.pages = new Pages(this)
this.browserApi = new BrowserApi(this)
this.webpackUtils = new WebpackUtils(this)
this.log = log
this.colors = colors
this.utils = publicUtils
Expand Down
8 changes: 0 additions & 8 deletions packages/@alterjs/saber/src/vue-renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ export class VueRenderer {
transformAssetUrls: {},
prettify: false,
},
api.webpackUtils.getCacheOptions('vue-loader', () => ({
// Increse `key` to invalid cache
'key': 0,
type,
'vue-loader': require('vue-loader/package.json').version,
'vue-template-compiler': require('vue-template-compiler/package.json')
.version,
})),
),
)

Expand Down
5 changes: 5 additions & 0 deletions packages/@alterjs/saber/src/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export default function webpackConfig(api: Saber, { type }: { type: string }): C

const fileNames = getFileNames(!api.dev)

// Disable cache if cache is disabled in saber config
if (api.config.build.cache === false) {
config.cache(false)
}

config.output
.publicPath(`${api.config.build.publicUrl}_saber/`)
.filename(fileNames.js)
Expand Down
52 changes: 5 additions & 47 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2356,7 +2356,7 @@
resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f"
integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==

"@types/json-schema@*", "@types/json-schema@^7.0.15", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9":
"@types/json-schema@*", "@types/json-schema@^7.0.15", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9":
version "7.0.15"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
Expand Down Expand Up @@ -3393,11 +3393,6 @@ buffer-from@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==

buffer-json@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/buffer-json/-/buffer-json-2.0.0.tgz#f73e13b1e42f196fe2fd67d001c7d7107edd7c23"
integrity sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw==

buffer@^5.2.0, buffer@^5.5.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
Expand Down Expand Up @@ -3480,18 +3475,6 @@ cacache@^17.0.0:
tar "^6.1.11"
unique-filename "^3.0.0"

[email protected]:
version "4.1.0"
resolved "https://registry.yarnpkg.com/cache-loader/-/cache-loader-4.1.0.tgz#9948cae353aec0a1fcb1eafda2300816ec85387e"
integrity sha512-ftOayxve0PwKzBF/GLsZNC9fJBXl8lkZE3TOsjkboHfVHVkL39iUEs1FO07A33mizmci5Dudt38UZrrYXDtbhw==
dependencies:
buffer-json "^2.0.0"
find-cache-dir "^3.0.0"
loader-utils "^1.2.3"
mkdirp "^0.5.1"
neo-async "^2.6.1"
schema-utils "^2.0.0"

call-bind-apply-helpers@^1.0.0, call-bind-apply-helpers@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.1.tgz#32e5892e6361b29b0b545ba6f7763378daca2840"
Expand Down Expand Up @@ -5258,15 +5241,6 @@ fill-range@^7.1.1:
dependencies:
to-regex-range "^5.0.1"

find-cache-dir@^3.0.0:
version "3.3.2"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.2.tgz#b30c5b6eff0730731aea9bbd9dbecbd80256d64b"
integrity sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==
dependencies:
commondir "^1.0.1"
make-dir "^3.0.2"
pkg-dir "^4.1.0"

find-up@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
Expand Down Expand Up @@ -7044,7 +7018,7 @@ loader-runner@^4.2.0:
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1"
integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==

loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2.3:
loader-utils@^1.0.2, loader-utils@^1.1.0:
version "1.4.2"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.2.tgz#29a957f3a63973883eb684f10ffd3d151fec01a3"
integrity sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==
Expand Down Expand Up @@ -7254,13 +7228,6 @@ make-dir@^2.1.0:
pify "^4.0.1"
semver "^5.6.0"

make-dir@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==
dependencies:
semver "^6.0.0"

make-fetch-happen@^10.0.3:
version "10.2.1"
resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-10.2.1.tgz#f5e3835c5e9817b617f2770870d9492d28678164"
Expand Down Expand Up @@ -7759,7 +7726,7 @@ negotiator@^0.6.3:
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd"
integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==

neo-async@^2.6.1, neo-async@^2.6.2:
neo-async@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==
Expand Down Expand Up @@ -8566,7 +8533,7 @@ pixelmatch@^4.0.2:
dependencies:
pngjs "^3.0.0"

pkg-dir@^4.1.0, pkg-dir@^4.2.0:
pkg-dir@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3"
integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==
Expand Down Expand Up @@ -9754,15 +9721,6 @@ sax@>=0.6.0, sax@^1.2.4:
resolved "https://registry.yarnpkg.com/sax/-/sax-1.3.0.tgz#a5dbe77db3be05c9d1ee7785dbd3ea9de51593d0"
integrity sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==

schema-utils@^2.0.0:
version "2.7.1"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"
integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==
dependencies:
"@types/json-schema" "^7.0.5"
ajv "^6.12.4"
ajv-keywords "^3.5.2"

schema-utils@^3.0.0, schema-utils@^3.2.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.3.0.tgz#f50a88877c3c01652a15b622ae9e9795df7a60fe"
Expand Down Expand Up @@ -9803,7 +9761,7 @@ [email protected]:
dependencies:
lru-cache "^6.0.0"

semver@^6.0.0, semver@^6.3.1:
semver@^6.3.1:
version "6.3.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
Expand Down

0 comments on commit 7551f99

Please sign in to comment.