-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
fix: #1210 - Add error handling for missing dependencies #1232
fix: #1210 - Add error handling for missing dependencies #1232
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/docsify-core/docsify-preview/gd5b2661n |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3a22fa4:
|
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.
LGTM
Thanks
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.
👍
@trusktr is it fixing/closing the issue that is mentioned ? |
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.
What other information is passed with the message
object to onWarn()
?
Ideally, we would check the path to verify that the unresolved import is something we want to import locally (i.e. from the src
directory). Otherwise, this change will throw an error if we ever release an ES6 module that imports external resources. In other words, this change will address the issue today, but it could cause builds to break down the road.
currently we need to check for modules that are installed. |
@jhildenbiddle A
|
Let's verify if Using the Before example from above as an example, try adding external: [
'medium-zoom'
] If If Finally, if the |
…:MLH-Fellowship/docsify into 1210-missing-dependencies-error-handling
@jhildenbiddle |
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.
Excellent!
Good to see rollup is doing the right thing. Much easier than handling the comparison with external
values ourselves. I also think we’ve saved a future dev some headaches if/when core leveraged external dependencies.
Nice work, @mohammedsahl! :)
* develop: docs: removed codefund docs and plugin (#1262) docs: remove bundle size from the home page and documentation (#1257) fix: search can not search the table header (#1256) fix: after setting the background image, the button is obscured (#1234) Fix: fixed onlycover flag in mobile (#1243) fix: Updated docs with instructions for installing specific version (fixes #780) (#1225) fix: Add error handling for missing dependencies (fixes #1210) (#1232) [documdocs: deploy docsify in docker. (#1241) docs: Add embed gist instructions to Embed Files (fixes #932 ) (#1238) chore: add changelog 4.11.4 [build] 4.11.4 feat: added html sanitizer for remote rendering (#1128)
Summary
This PR introduces an error handling method for missing dependencies as described in issue #1210 .
onwarn
intercepts warning messages and whenmessage.code === 'UNRESOLVED_IMPORT'
it means there is an unresolved or missing dependencies. Prior to this PR, a warning message would be logged to the console. The changes made throw an error instead, which can be handled by the appropriate error handlerBefore:
After:
Testing methdology
Run
npm install; npm run build:js
. The build should successful. This step is to ensure that there are no problems before deleteing a dependencyTake note of the dependencies in
package.json
https://github.com/docsifyjs/docsify/blob/13f91a4fcb52fb7757e7ecbb4262fd89247dabdd/package.json#L55-70
We will select
medium-zoom
to be the test dependecyDelete the appropriate directory from
node_modules
(node_modules/medium-zoom
for our testing purposes)Execute
npm run build:js
. An error message must be thrown, similar to the one above, labeled AfterRun
npm install; npm run build:js
. The build should successfulWhat kind of change does this PR introduce? (check at least one)
If changing the UI of default theme, please provide the before/after screenshot:
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
fix #xxx[,#xxx]
, where "xxx" is the issue number)You have tested in the following browsers: (Providing a detailed version will be better.)
If adding a new feature, the PR's description includes:
To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.
Other information:
lib
directory.