-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add PWAManifestTransformer #3404
Conversation
2f25bbb
to
7b72ca7
Compare
7b72ca7
to
f8ab22f
Compare
Hi, @devongovett! Could you check this please? Should I add something for rewriting urls? |
Looking good so far @Drapegnik! 😄 |
packages/transformers/pwa-manifest/src/PWAManifestTransformer.js
Outdated
Show resolved
Hide resolved
packages/transformers/pwa-manifest/src/PWAManifestTransformer.js
Outdated
Show resolved
Hide resolved
I decided to divide
|
import nullthrows from 'nullthrows'; | ||
|
||
const getSrcHandler = (opt = {}) => (asset, dep) => { | ||
dep.src = asset.addURLDependency(dep.src, opt); |
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.
I add this for urls rewriting and get following from this manifest:
{
"name": "pwa-webmanifest-example",
"icons": [
{
"src": "1eda49598769bd3a3cd2b1e31d3cfaff",
"sizes": "100x100",
"type": "image/png"
}
],
"screenshots": [
{
"src": "f432622196df181e7734bdfd95fa62d0",
"sizes": "100x100",
"type": "image/png"
},
{ "src": "" }
],
"serviceworker": { "src": "d771eacd0fc5e521bf134585524d4727" }
}
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.
Yep, those ids will be replaced later with urls once the final bundle names are known.
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.
How can I test it?
yarn build
parceldev build --no-cache packages/core/integration-tests/test/integration/pwa-manifest/inde
x.html
produces the same file (with ids)
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.
@devongovett @DeMoorJasper @padmaia @wbinnssmith,
Could you tell me where is this final replacement (ids -> urls) occurs?
Looks like .webmanifest
is ignored.
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.
never mind, I found - generateDepToBundlePath
)
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.
the problem was because .webmanifest
was being processed by RawPackager
, which returns stream, so typeof contents !== 'string'
and generateDepToBundlePath
was skipped
I fixed this by adding StringPackager
- not sure if this is the best way
packages/configs/default/index.json
Outdated
@@ -5,6 +5,7 @@ | |||
"@parcel/transformer-babel", | |||
"@parcel/transformer-js" | |||
], | |||
"manifest.json": ["@parcel/transformer-webext-manifest"], |
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.
This seems dangerous to me. Many things could be called manifest.json
in theory. I'd say, keep the web extension transformer as an official plugin, but don't include in the default config. That way, if you're writing a web extension, you can opt-in to the processing of manifest.json
, and it won't affect other apps.
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.
So, I add this logic to json-transformer
:
// handle webmanifest .json
if (asset.env.context === 'pwa-manifest') {
asset.type = 'webmanifest';
return [asset];
}
4fba6bf
to
73d0213
Compare
Ready to final review. |
@devongovett, hi! |
@devongovett, hey?) |
@Drapegnik looks like it has conflicts now, but I'd love to see @devongovett merge this. This will allow me to move many projects over to parcel and greatly reduce my complexity for my builds |
24cd209
to
5bc521c
Compare
@gnarmedia, I'm also really looking forward to some response from @devongovett. |
@@ -129,7 +129,8 @@ export default function collectDependencies( | |||
|
|||
if (tag === 'link' && attrs.rel === 'manifest' && attrs.href) { | |||
attrs.href = asset.addURLDependency(attrs.href, { | |||
isEntry: true | |||
isEntry: true, | |||
env: {context: 'pwa-manifest'} |
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.
I did rebase and now get:
Error: Received URL without a pathname.
something with moduleSpecifier
(new api?)
How do I properly add manifest
dep here?
@Drapegnik could you rebase this on v2 and fix the failing tests? Lemme know if you need any help with fixing tests |
5bc521c
to
e052b33
Compare
e052b33
to
ec02278
Compare
@DeMoorJasper, hi! after rebase I've got:
with maybe it's due |
We're current not including this in the HTML file yet since parcel has an issue bundling a JSON resouce from HTML. There is a PR that looks to resolve this issue (parcel-bundler/parcel#3404)
@Drapegnik apologies for not reaching out sooner and giving feedback on this plugin. I've tried to get the tests to pass a couple times, but also couldn't figure out why they were failing and deviated too much from this PR in my attempts to fix it to give proper feedback, so I never really got around to writing a structured review to get you going and eventually moved on to other issues... @mischnic apparently is working on fixing the issues with your PR, not entirely sure if we should close this one and move progress over to that PR? |
@DeMoorJasper, ok, but what about #3439, which depends on this one? |
@Drapegnik I assume that one will not be included in @mischnic 's PR |
↪️ Pull Request
Resolves #3362, Resolves #235, Resolves #301
✔️ PR Todo
WebManifestAsset
->PWAManifestTransformer
.json
webmanifest