SerKo
SerKo
Explore posts from servers
CDCloudflare Developers
Created by SerKo on 9/13/2024 in #pages-help
How can I ignore some sub modules when build ?
I have some private submodule in my repo but they dont need for building, how can I ignore them when building to prevent the fetch error from Cloudflare Pages builder ?
1 replies
NNuxt
Created by SerKo on 8/14/2024 in #❓・help
Tree-Shaking does not work when using multiple stores in Nuxt
When using Pinia in a Nuxt project and creating more than one store, tree-shaking does not work as expected. Here's an example to illustrate the issue:
// store/foo.ts
export const useFooStore = defineStore('foo', () => ({ foo: ref('foofoofoo') }));

// store/bar.ts
export const useBarStore = defineStore('bar', () => ({ bar: ref('barbarbar') }));
// store/foo.ts
export const useFooStore = defineStore('foo', () => ({ foo: ref('foofoofoo') }));

// store/bar.ts
export const useBarStore = defineStore('bar', () => ({ bar: ref('barbarbar') }));
<!-- app.vue -->
<script setup lang="ts">
if (false) {
// cannot tree-shake
console.log(useFooStore());
console.log(useBarStore());
}
</script>
<!-- app.vue -->
<script setup lang="ts">
if (false) {
// cannot tree-shake
console.log(useFooStore());
console.log(useBarStore());
}
</script>
After running nuxt generate, both the foo and bar stores are bundled into the output, even though they are inside a conditional block that should never run. However, if I use only one store within the if (false) block, tree-shaking works as expected:
<!-- app.vue -->
<script setup lang="ts">
if (false) {
// can tree-shake
console.log(useFooStore());
}
</script>
<!-- app.vue -->
<script setup lang="ts">
if (false) {
// can tree-shake
console.log(useFooStore());
}
</script>
In this case, the unused store is successfully tree-shaken and not included in the bundle. Reproduction https://stackblitz.com/edit/github-dylldh?file=app.vue GitHub Issue https://github.com/vuejs/pinia/issues/2738
2 replies
NNuxt
Created by SerKo on 3/4/2024 in #❓・help
How to use Nuxt to make a parallel route application?
No description
1 replies