-
Notifications
You must be signed in to change notification settings - Fork 2
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
Enable development without running the browser extension #20
Conversation
Update: After making good progress today (see the edited description of this PR), I have run into a problem with
I wonder why this works in the browser extension (although I have to admit I haven't succeeded in exporting a WXR even from the extension yet) but not in node. Maybe I need to register the core blocks first? |
When providing no configuration data, we already get an empty WXR:
|
This error that's preventing the test from running through successfully is not really an error, more of an "accepted error" for optional dependencies, see webpack/webpack#7713 (comment). Unfortunately, just addiing
As a counter-measure, I have simply excluded the error from the webpack output. Not the nicest workaround. |
Ok, now that I have circumvented the error message, I am finalizing the CLI syntax:
|
Does it make sense to include some HAR files in this PR for testing? |
I suppose it'd only make sense if we had a test extractor that would extract those specifically provided files there. I'll work on that. |
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 is looking really good! It was super easy to use, and I can see how easy it'll make development, when we don't have to constantly be waiting on the browser to refresh.
I left a couple of comments on things that I think could be improved. Additionally, I like @yoavf's suggestion of including some HAR files to use: it seems like we could safely generate a bunch of HAR files, replace tokens and such with placeholders, and commit them.
It's probably worth having two sets of HAR file tests: the package should have its own Jest tests to confirm that it's functioning correctly, independent of any functionality built against Wix (or other services). Additionally, for Wix specifically, I think this is a good opportunity to set up integration tests (in same vein as Gutenberg).
Finally, I noticed that running npm i
caused some changes to package-lock.json
. Could you double check that?
With the integration tests I am running into CommonJS vs ECMAScript module problems again. The code works when I run the webpack'ed script via It does make a difference if I run
vs.
Jest has some support for ECMAScript modules (see source/services/wix/extractors/communities-blog-app/test/index.js) but something prevents it from applying it to the module. |
The next step I took is to try and get out of mixing Common JS and ECMAScript modules and I converted everything to the latter. @pento has been using its syntax already in the extension ( A benefit of this is that the CLI tool can be run without webpack, so The negative aspect of this is, that building the extension is currently broken because I am stuck with converting the usage of While this now increases the size and impact of this PR a lot, I feel it makes sense to go with the more modern ESM, so I'll proceed. Maybe there is a way to split this PR but first I'd like to get it running. |
Ok, I finally made some real progress here. So now almost everything runs again, I am just running into some lint issues that I'll fix tomorrow.
Running
I'll look at this tomorrow. |
After some friendly help from @sirreal (thanks!), I reverted course (I kept the ESM approach in this branch for reference) and converted everything to Common JS. This means we no longer transpile, thus I removed
This change to CommonJS causes a conflict with #23, since it still uses ESM syntax. |
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.
Wow, this has turned into a huge project! 🙂
I've caught up with the conversations around the CJS vs ESM package loading syntax. While I have a personal preference for ESM, it's certainly not something that stands in the way of switching to using CJS, instead. I'd much prefer us to be able to use this tool, than to try and find workarounds for the oddities of build tools.
Thanks for taking care of the other issues I noted. I'm still seeing changes to package-lock.json
when I run npm i
on this branch: could you check if it's happening to you?
Aside from that, go ahead get this PR merged, so we can start using it properly. 🎉
I'll take care of rebasing #23 once that's done.
Me too, this is why I went down that road first. But turns out node just isn't ready yet and/or there is no agreement yet on how to load ESM from modules.
It didn't happen for me when you first posted but happens now, I just opted not to take care of this until this PR was ready to merge. I'll update it.
Thanks! Will do! |
This Pull Request adds the ability to use HAR files for local development.
By recording an HAR file using a browser's developer tools (usually there is something like "Save All as HAR" that can be used for that), either after having visited a supported site, or after an export took place, this HAR file can then be used for continued, local (=offline) development.
Specifically, this adds a CLI script
export-from-har.js
that accepts a HAR file as argument and then runs the business logic of exporting the site. Contrary to running in the browser and thus making HTTP requests to the real URLs, the requests are satisfied (if possible) by using the specified HAR file.This also allows quick testing with different sites by swapping out the locally saved HAR files.
To achieve this workflow, we have created a package
fetch-from-har
that implements a polyfill forfetch()
(which is not available in node anyway and would need its own polyfill) which is initialized with the HAR file to load the data from.Testing Instructions
In order to bridge the compatibility gap between ES6 used in the extension, and common JS used in node scripts, we're using webpack, hence during development you need to keep a
npm run watch
running in a tab.The script can then be executed with either of these:
For the moment, it'll output the exported WXR to the console.
As a side-product of the first implementation using
fetch-mock
(see #17), this also adds a jest test case.