fix: change cacheDir to userRoot/node_modules/.valaxy/cache to not mix deps

This commit is contained in:
YunYouJun 2024-12-16 21:54:43 +08:00
parent d8e2c27545
commit 31030df398
8 changed files with 93 additions and 75 deletions

1
.gitignore vendored
View File

@ -24,4 +24,3 @@ components.d.ts
# test
valaxy-blog

View File

@ -14,7 +14,7 @@ test.describe('enter docs', () => {
// Click the get started button
await page.click('.sese-btn')
// wait page load
await page.waitForURL(`${env.docs}/guide/getting-started`)
await page.waitForURL('/guide/getting-started')
// Expect a new url
await expect(page.locator('h1')).toHaveText('Getting Started')
})

View File

@ -86,9 +86,19 @@ export function getRollupOptions(options: ResolvedValaxyOptions) {
)}`,
)
const assetsDir = 'assets'
const rollupOptions: Rollup.RollupOptions = {
...options.config.vite?.build?.rollupOptions,
external: [],
// important so that each page chunk and the index export things for each
// other
preserveEntrySignatures: 'allow-extension',
output: {
assetFileNames: `${assetsDir}/[name].[hash].[ext]`,
entryFileNames: `${assetsDir}/[name].[hash].js`,
chunkFileNames() {
return `${assetsDir}/[name].[hash].js`
},
manualChunks(id, ctx) {
// move known framework code into a stable chunk so that
// custom theme changes do not invalidate hash for all pages
@ -102,6 +112,7 @@ export function getRollupOptions(options: ResolvedValaxyOptions) {
// lib
const libs = [
'@vueuse/motion',
'date-fns',
'luxon',
'vue-i18n',

View File

@ -50,7 +50,11 @@ export const defaultValaxyConfig: ValaxyNodeConfig = {
},
vite: {
build: { },
build: {
emptyOutDir: true,
// not inlined?
cssCodeSplit: false,
},
},
devtools: true,

View File

@ -31,6 +31,8 @@ const clientDeps = [
// vue
'vue',
'vue-router',
'unplugin-vue-router/data-loaders/basic',
'vue-i18n',
// dev
'@vue/devtools-api',
@ -90,7 +92,8 @@ export function createConfigPlugin(options: ResolvedValaxyOptions): Plugin {
// root: options.userRoot,
// can not transform valaxy/client/*.ts when use userRoot
root: options.clientRoot,
cacheDir: join(options.userRoot, 'node_modules/.vite'),
// cacheDir: join(options.userRoot, 'node_modules/.vite'),
cacheDir: join(options.userRoot, 'node_modules/.valaxy/cache'),
publicDir: join(options.userRoot, 'public'),
define: getDefine(options),
@ -121,7 +124,6 @@ export function createConfigPlugin(options: ResolvedValaxyOptions): Plugin {
}
if (isInstalledGlobally) {
injection.cacheDir = join(options.pkgRoot, 'node_modules/.vite')
// @ts-expect-error type cast
injection.resolve.alias.vue = `${resolveImportPath('vue/dist/vue.esm-browser.js', true)}`
}

View File

@ -59,8 +59,10 @@ export function createTransformMarkdown(options: ResolvedValaxyOptions) {
const loaderVuePath = path.resolve(options.pkgRoot, 'node/templates/loader.vue')
let loaderVue = fs.readFileSync(loaderVuePath, 'utf-8')
const pagePath = pageData.relativePath.slice('/pages'.length - 1, -'.md'.length)
loaderVue = loaderVue
.replace('/relativePath', pageData.relativePath.slice('/pages'.length - 1, -'.md'.length))
// adapt for /index
.replace('/relativePath', pagePath.endsWith('index') ? pagePath.replace(/\/index$/, '') : pagePath)
.replace('// custom basic loader', `return JSON.parse(\`${JSON.stringify(pageData)}\`)`)
code = loaderVue + code

View File

@ -52,7 +52,7 @@
"node": "^14.18.0 || >=16.0.0"
},
"scripts": {
"build": "rimraf dist && tsup --splitting",
"build": "rimraf dist && tsup",
"dev": "tsup --watch",
"preview": "vite preview",
"preview-https": "serve dist"

View File

@ -2105,8 +2105,8 @@ packages:
rollup:
optional: true
'@rollup/plugin-commonjs@28.0.1':
resolution: {integrity: sha512-+tNWdlWKbpB3WgBN7ijjYkq9X5uhjmcvyjEght4NmH5fAU++zfQzAJ6wumLS+dNcvwEZhKx2Z+skY8m7v0wGSA==}
'@rollup/plugin-commonjs@28.0.2':
resolution: {integrity: sha512-BEFI2EDqzl+vA1rl97IDRZ61AIwGH093d9nz8+dThxJNH8oSoB7MjWvPCX3dkaK1/RCJ/1v/R1XB15FuSs0fQw==}
engines: {node: '>=16.0.0 || 14 >= 14.17'}
peerDependencies:
rollup: ^2.68.0||^3.0.0||^4.0.0
@ -2123,8 +2123,8 @@ packages:
rollup:
optional: true
'@rollup/plugin-node-resolve@15.3.0':
resolution: {integrity: sha512-9eO5McEICxMzJpDW9OnMYSv4Sta3hmt7VtBFz5zR9273suNOydOyq/FrGeGy+KsTRFm8w0SLVhzig2ILFT63Ag==}
'@rollup/plugin-node-resolve@15.3.1':
resolution: {integrity: sha512-tgg6b91pAybXHJQMAAwW9VuWBO6Thi+q7BCNARLwSqlmsHz0XYURtGvh/AuwSADXSI4h/2uHbs7s4FzlZDGSGA==}
engines: {node: '>=14.0.0'}
peerDependencies:
rollup: ^2.78.0||^3.0.0||^4.0.0
@ -2132,8 +2132,8 @@ packages:
rollup:
optional: true
'@rollup/plugin-replace@6.0.1':
resolution: {integrity: sha512-2sPh9b73dj5IxuMmDAsQWVFT7mR+yoHweBaXG2W/R8vQ+IWZlnaI7BR7J6EguVQUp1hd8Z7XuozpDjEKQAAC2Q==}
'@rollup/plugin-replace@6.0.2':
resolution: {integrity: sha512-7QaYCf8bqF04dOy7w/eHmJeNExxTYwvKAmlSAH/EaWWUzbT0h5sbF6bktFoX/0F/0qwng5/dWFMyf3gzaM8DsQ==}
engines: {node: '>=14.0.0'}
peerDependencies:
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
@ -3222,8 +3222,8 @@ packages:
resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==}
engines: {node: '>=8'}
arraybuffer.prototype.slice@1.0.3:
resolution: {integrity: sha512-bMxMKAjg13EBSVscxTaYA4mRc5t1UAXa2kXiGTNfZ079HIWXEkKmkgFrh/nJqamaLSrXO5H4WFFkPEaLJWbs3A==}
arraybuffer.prototype.slice@1.0.4:
resolution: {integrity: sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==}
engines: {node: '>= 0.4'}
artalk@2.9.1:
@ -3372,8 +3372,8 @@ packages:
resolution: {integrity: sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==}
engines: {node: '>= 0.4'}
call-bound@1.0.2:
resolution: {integrity: sha512-0lk0PHFe/uz0vl527fG9CgdE9WdafjDbCXvBbs+LUv000TVt2Jjhqbs4Jwm8gz070w8xXyEAxrPOMullsxXeGg==}
call-bound@1.0.3:
resolution: {integrity: sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==}
engines: {node: '>= 0.4'}
callsites@3.1.0:
@ -4965,8 +4965,8 @@ packages:
function-bind@1.1.2:
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
function.prototype.name@1.1.6:
resolution: {integrity: sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==}
function.prototype.name@1.1.7:
resolution: {integrity: sha512-2g4x+HqTJKM9zcJqBSpjoRmdcPFtJM60J3xJisTQSXBWka5XqyBN/2tNUgma1mztTXyDuUsEtYe5qcs7xYzYQA==}
engines: {node: '>= 0.4'}
functions-have-names@1.2.3:
@ -5434,8 +5434,8 @@ packages:
resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==}
engines: {node: '>= 0.4'}
is-core-module@2.15.1:
resolution: {integrity: sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==}
is-core-module@2.16.0:
resolution: {integrity: sha512-urTSINYfAYgcbLb0yDQ6egFm6h3Mo1DcF9EkyXSRjjzdHbsulg01qhwWuXdOoUBuTkbQ80KDboXa0vFJ+BDH+g==}
engines: {node: '>= 0.4'}
is-data-view@1.0.2:
@ -6369,8 +6369,8 @@ packages:
engines: {node: '>=10'}
hasBin: true
mkdist@2.0.1:
resolution: {integrity: sha512-inFY4oabZuwSS+R5NsswuEtSmksxPffLwTHufANmxJ1UL7oYnRZNb7WVZSkmrJMoPnyZK9Ru7vzDqGpoDdmrSw==}
mkdist@2.1.0:
resolution: {integrity: sha512-FhJRzoA2GEZr7X9S8S8SR5BcuGwgGi6IZKnJUHlMkRHUBJAtTU3xfIIcHnK4t9M/B9zK1ffpE+vGSS1003R7Dw==}
hasBin: true
peerDependencies:
sass: ^1.83.0
@ -7506,8 +7506,8 @@ packages:
resolve-protobuf-schema@2.1.0:
resolution: {integrity: sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==}
resolve@1.22.8:
resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==}
resolve@1.22.9:
resolution: {integrity: sha512-QxrmX1DzraFIi9PxdG5VkRfRwIgjwyud+z/iBwfRRrVmHc+P9Q7u2lSSpQ6bjr2gy5lrqIiU9vb6iAeGf2400A==}
hasBin: true
restore-cursor@5.1.0:
@ -8158,11 +8158,11 @@ packages:
resolution: {integrity: sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==}
engines: {node: '>=14.0.0'}
tldts-core@6.1.67:
resolution: {integrity: sha512-12K5O4m3uUW6YM5v45Z7wc6NTSmAYj4Tq3de7eXghZkp879IlfPJrUWeWFwu1FS94U5t2vwETgJ1asu8UGNKVQ==}
tldts-core@6.1.68:
resolution: {integrity: sha512-85TdlS/DLW/gVdf2oyyzqp3ocS30WxjaL4la85EArl9cHUR/nizifKAJPziWewSZjDZS71U517/i6ciUeqtB5Q==}
tldts@6.1.67:
resolution: {integrity: sha512-714VbegxoZ9WF5/IsVCy9rWXKUpPkJq87ebWLXQzNawce96l5oRrRf2eHzB4pT2g/4HQU1dYbu+sdXClYxlDKQ==}
tldts@6.1.68:
resolution: {integrity: sha512-JKF17jROiYkjJPT73hUTEiTp2OBCf+kAlB+1novk8i6Q6dWjHsgEjw9VLiipV4KTJavazXhY1QUXyQFSem2T7w==}
hasBin: true
to-regex-range@5.0.1:
@ -10265,7 +10265,7 @@ snapshots:
'@rushstack/ts-command-line': 4.23.2(@types/node@22.10.2)
lodash: 4.17.21
minimatch: 3.0.8
resolve: 1.22.8
resolve: 1.22.9
semver: 7.5.4
source-map: 0.6.1
typescript: 5.4.2
@ -10277,7 +10277,7 @@ snapshots:
'@microsoft/tsdoc': 0.15.1
ajv: 8.12.0
jju: 1.4.0
resolve: 1.22.8
resolve: 1.22.9
'@microsoft/tsdoc@0.15.1': {}
@ -10457,7 +10457,7 @@ snapshots:
optionalDependencies:
rollup: 4.28.1
'@rollup/plugin-commonjs@28.0.1(rollup@4.28.1)':
'@rollup/plugin-commonjs@28.0.2(rollup@4.28.1)':
dependencies:
'@rollup/pluginutils': 5.1.4(rollup@4.28.1)
commondir: 1.0.1
@ -10475,17 +10475,17 @@ snapshots:
optionalDependencies:
rollup: 4.28.1
'@rollup/plugin-node-resolve@15.3.0(rollup@4.28.1)':
'@rollup/plugin-node-resolve@15.3.1(rollup@4.28.1)':
dependencies:
'@rollup/pluginutils': 5.1.4(rollup@4.28.1)
'@types/resolve': 1.20.2
deepmerge: 4.3.1
is-module: 1.0.0
resolve: 1.22.8
resolve: 1.22.9
optionalDependencies:
rollup: 4.28.1
'@rollup/plugin-replace@6.0.1(rollup@4.28.1)':
'@rollup/plugin-replace@6.0.2(rollup@4.28.1)':
dependencies:
'@rollup/pluginutils': 5.1.4(rollup@4.28.1)
magic-string: 0.30.15
@ -10565,14 +10565,14 @@ snapshots:
fs-extra: 7.0.1
import-lazy: 4.0.0
jju: 1.4.0
resolve: 1.22.8
resolve: 1.22.9
semver: 7.5.4
optionalDependencies:
'@types/node': 22.10.2
'@rushstack/rig-package@0.5.3':
dependencies:
resolve: 1.22.8
resolve: 1.22.9
strip-json-comments: 3.1.1
'@rushstack/terminal@0.14.4(@types/node@22.10.2)':
@ -11801,7 +11801,7 @@ snapshots:
array-union@2.1.0: {}
arraybuffer.prototype.slice@1.0.3:
arraybuffer.prototype.slice@1.0.4:
dependencies:
array-buffer-byte-length: 1.0.1
call-bind: 1.0.8
@ -11810,7 +11810,6 @@ snapshots:
es-errors: 1.3.0
get-intrinsic: 1.2.6
is-array-buffer: 3.0.4
is-shared-array-buffer: 1.0.3
artalk@2.9.1(marked@15.0.4):
dependencies:
@ -11862,7 +11861,7 @@ snapshots:
dependencies:
'@babel/runtime': 7.26.0
cosmiconfig: 7.1.0
resolve: 1.22.8
resolve: 1.22.9
bail@1.0.5: {}
@ -12006,9 +12005,9 @@ snapshots:
get-intrinsic: 1.2.6
set-function-length: 1.2.2
call-bound@1.0.2:
call-bound@1.0.3:
dependencies:
call-bind: 1.0.8
call-bind-apply-helpers: 1.0.1
get-intrinsic: 1.2.6
callsites@3.1.0: {}
@ -13299,7 +13298,7 @@ snapshots:
es-abstract@1.23.5:
dependencies:
array-buffer-byte-length: 1.0.1
arraybuffer.prototype.slice: 1.0.3
arraybuffer.prototype.slice: 1.0.4
available-typed-arrays: 1.0.7
call-bind: 1.0.8
data-view-buffer: 1.0.1
@ -13310,7 +13309,7 @@ snapshots:
es-object-atoms: 1.0.0
es-set-tostringtag: 2.0.3
es-to-primitive: 1.3.0
function.prototype.name: 1.1.6
function.prototype.name: 1.1.7
get-intrinsic: 1.2.6
get-symbol-description: 1.0.2
globalthis: 1.0.4
@ -13488,8 +13487,8 @@ snapshots:
eslint-import-resolver-node@0.3.9:
dependencies:
debug: 3.2.7
is-core-module: 2.15.1
resolve: 1.22.8
is-core-module: 2.16.0
resolve: 1.22.9
transitivePeerDependencies:
- supports-color
@ -14020,12 +14019,13 @@ snapshots:
function-bind@1.1.2: {}
function.prototype.name@1.1.6:
function.prototype.name@1.1.7:
dependencies:
call-bind: 1.0.8
define-properties: 1.2.1
es-abstract: 1.23.5
functions-have-names: 1.2.3
hasown: 2.0.2
is-callable: 1.2.7
functions-have-names@1.2.3: {}
@ -14566,7 +14566,7 @@ snapshots:
is-boolean-object@1.2.1:
dependencies:
call-bound: 1.0.2
call-bound: 1.0.3
has-tostringtag: 1.0.2
is-buffer@2.0.5: {}
@ -14577,19 +14577,19 @@ snapshots:
is-callable@1.2.7: {}
is-core-module@2.15.1:
is-core-module@2.16.0:
dependencies:
hasown: 2.0.2
is-data-view@1.0.2:
dependencies:
call-bound: 1.0.2
call-bound: 1.0.3
get-intrinsic: 1.2.6
is-typed-array: 1.1.13
is-date-object@1.1.0:
dependencies:
call-bound: 1.0.2
call-bound: 1.0.3
has-tostringtag: 1.0.2
is-decimal@1.0.4: {}
@ -14661,7 +14661,7 @@ snapshots:
is-regex@1.2.1:
dependencies:
call-bound: 1.0.2
call-bound: 1.0.3
gopd: 1.2.0
has-tostringtag: 1.0.2
hasown: 2.0.2
@ -14683,7 +14683,7 @@ snapshots:
is-symbol@1.1.1:
dependencies:
call-bound: 1.0.2
call-bound: 1.0.3
has-symbols: 1.1.0
safe-regex-test: 1.1.0
@ -14701,7 +14701,7 @@ snapshots:
is-weakref@1.1.0:
dependencies:
call-bound: 1.0.2
call-bound: 1.0.3
is-weakset@2.0.3:
dependencies:
@ -15709,7 +15709,7 @@ snapshots:
mkdirp@1.0.4: {}
mkdist@2.0.1(sass@1.83.0)(typescript@5.6.3)(vue-tsc@2.0.17(typescript@5.6.3))(vue@3.5.13(typescript@5.6.3)):
mkdist@2.1.0(sass@1.83.0)(typescript@5.6.3)(vue-tsc@2.0.17(typescript@5.6.3))(vue@3.5.13(typescript@5.6.3)):
dependencies:
autoprefixer: 10.4.20(postcss@8.4.49)
citty: 0.1.6
@ -15801,7 +15801,7 @@ snapshots:
normalize-package-data@2.5.0:
dependencies:
hosted-git-info: 2.8.9
resolve: 1.22.8
resolve: 1.22.9
semver: 5.7.2
validate-npm-package-license: 3.0.4
@ -16970,9 +16970,9 @@ snapshots:
dependencies:
protocol-buffers-schema: 3.6.0
resolve@1.22.8:
resolve@1.22.9:
dependencies:
is-core-module: 2.15.1
is-core-module: 2.16.0
path-parse: 1.0.7
supports-preserve-symlinks-flag: 1.0.0
@ -17054,7 +17054,7 @@ snapshots:
safe-array-concat@1.1.3:
dependencies:
call-bind: 1.0.8
call-bound: 1.0.2
call-bound: 1.0.3
get-intrinsic: 1.2.6
has-symbols: 1.1.0
isarray: 2.0.5
@ -17065,7 +17065,7 @@ snapshots:
safe-regex-test@1.1.0:
dependencies:
call-bound: 1.0.2
call-bound: 1.0.3
es-errors: 1.3.0
is-regex: 1.2.1
@ -17207,14 +17207,14 @@ snapshots:
side-channel-map@1.0.1:
dependencies:
call-bound: 1.0.2
call-bound: 1.0.3
es-errors: 1.3.0
get-intrinsic: 1.2.6
object-inspect: 1.13.3
side-channel-weakmap@1.0.2:
dependencies:
call-bound: 1.0.2
call-bound: 1.0.3
es-errors: 1.3.0
get-intrinsic: 1.2.6
object-inspect: 1.13.3
@ -17434,7 +17434,7 @@ snapshots:
string.prototype.trim@1.2.10:
dependencies:
call-bind: 1.0.8
call-bound: 1.0.2
call-bound: 1.0.3
define-data-property: 1.1.4
define-properties: 1.2.1
es-abstract: 1.23.5
@ -17444,7 +17444,7 @@ snapshots:
string.prototype.trimend@1.0.9:
dependencies:
call-bind: 1.0.8
call-bound: 1.0.2
call-bound: 1.0.3
define-properties: 1.2.1
es-object-atoms: 1.0.0
@ -17744,11 +17744,11 @@ snapshots:
tinyspy@3.0.2: {}
tldts-core@6.1.67: {}
tldts-core@6.1.68: {}
tldts@6.1.67:
tldts@6.1.68:
dependencies:
tldts-core: 6.1.67
tldts-core: 6.1.68
to-regex-range@5.0.1:
dependencies:
@ -17770,7 +17770,7 @@ snapshots:
tough-cookie@5.0.0:
dependencies:
tldts: 6.1.67
tldts: 6.1.68
tr46@1.0.1:
dependencies:
@ -17938,10 +17938,10 @@ snapshots:
unbuild@3.0.1(sass@1.83.0)(typescript@5.6.3)(vue-tsc@2.0.17(typescript@5.6.3))(vue@3.5.13(typescript@5.6.3)):
dependencies:
'@rollup/plugin-alias': 5.1.1(rollup@4.28.1)
'@rollup/plugin-commonjs': 28.0.1(rollup@4.28.1)
'@rollup/plugin-commonjs': 28.0.2(rollup@4.28.1)
'@rollup/plugin-json': 6.1.0(rollup@4.28.1)
'@rollup/plugin-node-resolve': 15.3.0(rollup@4.28.1)
'@rollup/plugin-replace': 6.0.1(rollup@4.28.1)
'@rollup/plugin-node-resolve': 15.3.1(rollup@4.28.1)
'@rollup/plugin-replace': 6.0.2(rollup@4.28.1)
'@rollup/pluginutils': 5.1.4(rollup@4.28.1)
citty: 0.1.6
consola: 3.2.3
@ -17950,7 +17950,7 @@ snapshots:
hookable: 5.5.3
jiti: 2.4.1
magic-string: 0.30.15
mkdist: 2.0.1(sass@1.83.0)(typescript@5.6.3)(vue-tsc@2.0.17(typescript@5.6.3))(vue@3.5.13(typescript@5.6.3))
mkdist: 2.1.0(sass@1.83.0)(typescript@5.6.3)(vue-tsc@2.0.17(typescript@5.6.3))(vue@3.5.13(typescript@5.6.3))
mlly: 1.7.3
pathe: 1.1.2
pkg-types: 1.2.1
@ -18861,8 +18861,8 @@ snapshots:
which-builtin-type@1.2.1:
dependencies:
call-bound: 1.0.2
function.prototype.name: 1.1.6
call-bound: 1.0.3
function.prototype.name: 1.1.7
has-tostringtag: 1.0.2
is-async-function: 2.0.0
is-date-object: 1.1.0