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

Hoist markbind package dependencies #1253

Merged
merged 5 commits into from
Jun 28, 2020

Conversation

ang-zeyu
Copy link
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [x] Other, please explain: Dependency maintainability

What is the rationale for this request?

  • Reduce dependency management overhead in managing the duplicated dependencies in both packages, many of which markbind-cli does not use as well.
  • Update all relative markbind imports to use the markbind package import instead to discourage writing long relative imports

What changes did you make? (Give an overview)

  • removed all dependencies which are being used in markbind but not markbind-cli, then running a `npm install && npm install src\lib\markbind
  • added a missing markdown-it dependency for markbind
  • use the patched version of markdown from the markbind package for one of the tests instead of markdown-it to remove the markdown-it dependency; We have quite a few patches / added plugins for the behaviour in markdown-it which may interfere with the the plugin being tested itself as well.
  • use package imports for markbind-cli

Proposed commit message: (wrap lines at 72 characters)
Hoist markbind core package dependencies

Markbind-cli lists many packages under as its dependencies which are
used by the core markbind package but not markbind-cli.
Importing files from markbind from markbind-cli also requires writing
long relative imports.

Let's use npm install instead to hoist these packages to
markbind-cli's node_modules.
Let's also use package imports for importing the core markbind library
files.

@ang-zeyu ang-zeyu force-pushed the hoist-dependencies branch 2 times, most recently from 928e2d2 to 596fdd5 Compare June 16, 2020 11:24
@@ -1,4 +1,5 @@
*.min.*
node_modules
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this as there are still some unhoisted dependencies (moment) that will be installed in markbind (lib)

@@ -135,7 +135,6 @@ fs.copySync = (src, dest) => {
*/
fs.readJsonSync = filePath => JSON.parse(fs.readFileSync(filePath, 'utf8'));


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these occur due to dependency upgrades of eslint

@ang-zeyu ang-zeyu force-pushed the hoist-dependencies branch 3 times, most recently from e07e7e6 to 55718c5 Compare June 26, 2020 14:00
@ang-zeyu ang-zeyu closed this Jun 26, 2020
@ang-zeyu ang-zeyu reopened this Jun 26, 2020
@ang-zeyu ang-zeyu force-pushed the hoist-dependencies branch from 55718c5 to 7075664 Compare June 26, 2020 14:08
Copy link
Contributor Author

@ang-zeyu ang-zeyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acjh what do you think of this?
The downside is that you'd have to run npm install src/lib/markbind (provided as npm run install:markbind) when upgrading the core package's dependencies, something obscure (as opposed to cd src/lib/markbind && npm install) I noted in the devGuide.


I noticed node's hoisting feature does not hoist devDependencies as well, which is somewhat of a bummer for deduplicating markbind-cli - frontend/components dev dependencies later on (in another PR).

"install:components": "cd frontend/components && npm install",
"install:markbind": "npm install src/lib/markbind",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hence, for example if you only updated the markbind core package's dependencies, simply run install:markbind.
If multiple packages had their dependencies upgraded, run install:all instead. (documented under workflow under dev guide)

docs/devGuide/workflow.md Outdated Show resolved Hide resolved
docs/devGuide/workflow.md Show resolved Hide resolved
docs/devGuide/workflow.md Outdated Show resolved Hide resolved
docs/devGuide/workflow.md Show resolved Hide resolved
src/Page.js Outdated Show resolved Hide resolved
src/Page.js Show resolved Hide resolved
test/unit/markdown-it-icons.test.js Outdated Show resolved Hide resolved
src/Site.js Show resolved Hide resolved
src/plugins/default/markbind-plugin-footnotes-popovers.js Outdated Show resolved Hide resolved
test/unit/parser.test.js Outdated Show resolved Hide resolved
@ang-zeyu
Copy link
Contributor Author

Thanks for the review @acjh! Pushed the relevant fixups

@@ -27,6 +27,7 @@
"markdown-it-emoji": "^1.4.0",
"markdown-it-imsize": "^2.0.1",
"markdown-it-ins": "^2.0.0",
"markdown-it-linkify-images": "^1.1.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we adjust the order of the sections in both package.json in this PR?
Or will it significantly mess up the diff since we're modifying packages too?

Ref: #1248 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm perhaps the one that would move src/lib/markbind into packages/markbind? Would be more suitable relevant I think
The diffs wouldn't be too big if we do it here either though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with either, if it doesn't significantly mess up the diff in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'll give it a try, will stash it if it's too much

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diffs seem ok (Fixup hoist markbind core package dependencies commit); I extracted out the jest config into a separate file for consistency as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4da36b4 should be its own commit instead of a fixup.
Otherwise it messes up the diff since it's no longer obvious that we removed several packages.

@ang-zeyu ang-zeyu force-pushed the hoist-dependencies branch from 37b17d3 to 32c0940 Compare June 28, 2020 02:43
jest.config.js Outdated Show resolved Hide resolved
src/lib/markbind/package.json Show resolved Hide resolved
@@ -27,6 +27,7 @@
"markdown-it-emoji": "^1.4.0",
"markdown-it-imsize": "^2.0.1",
"markdown-it-ins": "^2.0.0",
"markdown-it-linkify-images": "^1.1.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4da36b4 should be its own commit instead of a fixup.
Otherwise it messes up the diff since it's no longer obvious that we removed several packages.

ang-zeyu added 5 commits June 28, 2020 12:33
Markbind-cli lists many packages under as its dependencies which are
used by markbind but not markbind-cli.

Let's use npm install <folder> instead to hoist these packages to
markbind-cli's node_modules.
The package.json files of the various packages are not standardised in
their ordering and content.

Let's add and reorder the appropriate fields to do so.
Fix up use package imports for markbind core library


Fix up use package import for markbind
In hoisting markbind dependencies, npm install also caused some of
eslint's dependencies' versions in package-lock.json to increase.

Let's update the source files affected by npm run lintfix.
Fix up add updating dependencies section to devGuide
@ang-zeyu ang-zeyu force-pushed the hoist-dependencies branch from 32c0940 to 6c734d7 Compare June 28, 2020 04:33
@ang-zeyu
Copy link
Contributor Author

4da36b4 should be its own commit instead of a fixup.

Done, the new order:

Untitled

@ang-zeyu
Copy link
Contributor Author

ang-zeyu commented Jun 28, 2020

Thanks again for the review @acjh! 😄

Will be dealing with the packages/markbind next, on that note, should we:

  1. move frontend/components into packages/components as well?
  2. improve markbind/markbind-cli separation by moving assets into the markbind core package packages/markbind

an alternative to (2) being to create another package for assets, but it seems a little awkward having a package just for that

@ang-zeyu ang-zeyu added this to the v2.15.0 milestone Jun 28, 2020
@ang-zeyu ang-zeyu merged commit a13810c into MarkBind:master Jun 28, 2020
@acjh
Copy link
Contributor

acjh commented Jun 28, 2020

Will be dealing with the packages/markbind next, on that note, should we:

  1. move frontend/components into packages/components as well?

Sounds good.

Alternatives for the record:

  • src/lib/markbindpackages/markbind or packages/core
  • frontend/componentspackages/components or packages/vue-components
  1. improve markbind/markbind-cli separation by moving assets into the markbind core package packages/markbind

an alternative to (2) being to create another package for assets, but it seems a little awkward having a package just for that

Looks like asset/ is only used by Site.js, which is currently in markbind-cli?

@ang-zeyu
Copy link
Contributor Author

Alternatives for the record:

I'll go with the latter options, they look more semantic 😁

Looks like asset/ is only used by Site.js, which is currently in markbind-cli?

yup, with the eventual goal being to move Site/Page.js + all other non-cli functionality into packages/markbind or packages/core. We could deal with this in one go in a later PR though, suggesting it now since we're touching on "frontend"

@acjh
Copy link
Contributor

acjh commented Jun 28, 2020

Looks like asset/ is only used by Site.js, which is currently in markbind-cli?

yup, with the eventual goal being to move Site/Page.js + all other non-cli functionality into packages/markbind or packages/core. We could deal with this in one go in a later PR though, suggesting it now since we're touching on "frontend"

Let's do it in a later PR.

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

Successfully merging this pull request may close these issues.

2 participants