Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin/alexander vidoni/fix missing dependency #25

Conversation

alexander-vidoni
Copy link

Description

This PR fixes two bugs:

  1. ADD a missing dependency fast-glob to package.json
  2. FIX a typo in six files which make the the service-worker.js failing during installation in the browser.

/publish

…svelte

In Svelte and SvelteKit there is no index.html due to the routing. So / is the entrypoint to the app. I think that this should be reflected in the createHandlerBoundRoute() function. So I changed it to / and the uncaugth Error from the browsers console does no longer show up. Precaching works correct and the registration of the sevice woker is now possible without moving to state "redundant" any more.
I think that it was just a typo, because in the .ts files of template-custom-svelte-kit it was already set to "/".
@userquin
Copy link
Member

/publish

Copy link

pkg-pr-new bot commented Oct 18, 2024

pnpm add https://pkg.pr.new/@vite-pwa/create-pwa@25

commit: 6454eab

@userquin
Copy link
Member

We don't use fast-glob, replaced with tinyglobby, why is this dependency needed?

@alexander-vidoni
Copy link
Author

When running npm run build in the created sveltekit project folder the missing of fast-glob exits with a fatal error.

How to replay:

CREATE

npm create @vite-pwa/pwa@latest
✔ Project name: … vite-project
✔ Select a framework: › Svelte
✔ Select a variant: › SvelteKit ↗
✔ PWA Name: … vite-project
✔ PWA Short Name: … vite-project
✔ PWA Description: …
✔ Theme color: … #ffffff
✔ Select a strategy: › injectManifest
✔ Select a behavior: › Auto update
✔ Enable periodic SW updates? … no / yes
✔ Show offline ready prompt? … no / yes
✔ Generate PWA Assets Icons on the fly? … no / yes

create-svelte version 6.4.0

┌ Welcome to SvelteKit!

◇ Which Svelte app template?
│ Skeleton project

◇ Add type checking with TypeScript?
│ No

◇ Select additional options (use arrow keys/space bar)
│ none

└ Your project is ready!

Install more integrations with:
npx svelte-add

Next steps:
1: cd vite-project
2: npm install
3: git init && git add -A && git commit -m "Initial commit" (optional)
4: npm run dev -- --open

To close the dev server, hit Ctrl-C

Stuck? Visit us at https://svelte.dev/chat

PWA configuration done. Now run:

cd vite-project
npm install
npm run dev

INSTALL

npm install
npm WARN deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm WARN deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead

added 434 packages, and audited 435 packages in 23s

91 packages are looking for funding
run npm fund for details

4 low severity vulnerabilities

To address all issues (including breaking changes), run:
npm audit fix --force

Run npm audit for details.

BUILD

npm run build

[email protected] build
vite build

ERROR

npm run build

[email protected] build
vite build

failed to load config from [...] vite-project/vite.config.js
error during build:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'fast-glob' imported from [...] vite-project/node_modules/@vite-pwa/sveltekit/dist/index.mjs

FIX

npm i fast-glob

@alexander-vidoni
Copy link
Author

alexander-vidoni commented Oct 18, 2024

We don't use fast-glob, replaced with tinyglobby, why is this dependency needed?

Yes, but not in version 2.0.0 of unbuild.

The change from fast-glob to tinyglobby takes place first in unbuild v3.0.0-rc.8.

unbuild builds sveltekit and create-pwa imports sveltekit as dependency in the template-sveltekit.

As long as there is no release v3.0.0 for unbuild there is no change possible for sveltekit and no fix of the missing dependency in a project created by vite-pwa/create-pwa.

Until the release of v3.0.0 of unbuild is out - my solution would be a simple "hot fix" i think.

@userquin
Copy link
Member

Looks like we've some problem in the kit integration...

@userquin
Copy link
Member

userquin commented Oct 18, 2024

This line shouldn't be there: https://github.com/vite-pwa/sveltekit/blob/4cc62f598483173775308a143df5da9a13450bb0/src/plugins/SvelteKitPlugin.ts#L7

We need to use tinyglobby instead.

@alexander-vidoni
Copy link
Author

I edited my post look at: #25 (comment)

@alexander-vidoni
Copy link
Author

I tested building sveltekit with unbuild v3.0.0.rc8 and then there is no more fast-glob in the build of sveltekit.

@userquin
Copy link
Member

userquin commented Oct 19, 2024

This is a dev dependency in kit repo for runtime not for build, tinyglobby is external when building the distro, the problem is about the @ts-expect-error, there is no dependency in the package.json.

I'll release a new patch version... then we can just update the version here and remove fast-glob also from this PR.

@userquin
Copy link
Member

@alexander-vidoni can you check with vite-pwa/sveltekit#92 (comment) ?

@alexander-vidoni
Copy link
Author

alexander-vidoni commented Oct 19, 2024

@userquin it's working in my scenario. Thank you for your help!

@userquin
Copy link
Member

userquin commented Oct 19, 2024

@alexander-vidoni can you remove fast-glob from this PR? I'm finish testing and will release a patch, then we can just update the dependencies here or in another PR.

EDIT: remove fast-glob, once released I'm going to send a new PR here and merge this PR and release a new version also here.

@userquin
Copy link
Member

userquin commented Oct 19, 2024

ok, the generatesSW strategy is fine in this repo

@alexander-vidoni alexander-vidoni deleted the origin/alexander-vidoni/fix-missing-dependency branch October 19, 2024 01:00
@userquin
Copy link
Member

why do you close this PR? It will fix the navigate fallback.

@alexander-vidoni
Copy link
Author

why do you close this PR? It will fix the navigate fallback.

Sorry, it's my first time trying to contribute to a project. i did not really know what i am doing. Sorry for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants