feat(utils-build): new utility to build plugins#5612
feat(utils-build): new utility to build plugins#5612Josh-Cena wants to merge 16 commits intofacebook:mainfrom
Conversation
|
✔️ [V2] 🔨 Explore the source changes: f8889f5 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/62107fad910e340008db3c74 😎 Browse the preview: https://deploy-preview-5612--docusaurus-2.netlify.app |
|
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5612--docusaurus-2.netlify.app/ |
There was a problem hiding this comment.
Looks like it's almost working
- Not a fan of the package name, we should make it more generic
- Can we reuse code from babel cli for the watch mode (eventually call the cli?)? Is it really needed to implement our own? Is our implementation similar to Babel cli?
- Watch mode does not permit to work on theme with hot reload
- theme / js-theme: unnecessary duplication (main also duplicates, but it's a good opportunity to fix this)
- Build size bot reports important build size changes, any idea why?
Size Change: -8.3 kB (-1%)
Total Size: 816 kB
| Filename | Size | Change |
|---|---|---|
website/build/assets/js/main.********.js |
404 kB | -8.29 kB (-2%) |
ℹ️ View Unchanged
| Filename | Size | Change |
|---|---|---|
website/.docusaurus/globalData.json |
36.7 kB | 0 B |
website/build/assets/css/styles.********.css |
94 kB | 0 B |
website/build/blog/2017/12/14/introducing-docusaurus/index.html |
67 kB | 0 B |
website/build/blog/index.html |
38 kB | 0 B |
website/build/docs/index.html |
44.5 kB | -5 B (0%) |
website/build/docs/installation/index.html |
52.7 kB | -5 B (0%) |
website/build/index.html |
30.8 kB | 0 B |
website/build/tests/docs/index.html |
25.3 kB | 0 B |
website/build/tests/docs/standalone/index.html |
22.9 kB | 0 B |
| '@babel/plugin-proposal-nullish-coalescing-operator', | ||
| '@babel/plugin-proposal-optional-chaining', | ||
| ], | ||
| })?.code ?? '' |
There was a problem hiding this comment.
when does fallback happen? empty file?
There was a problem hiding this comment.
The Babel doc isn't clear on this, and I've just kept it for testing purposes (it did return null a while ago). I'll keep in mind to remove & retest when we're merging this
There was a problem hiding this comment.
For now I'd rather throw if code is undefined, this way we'll find out the undocumented edge cases more easily and decide how to fix them
Any suggestions? I plan to add
I've read the cli code and it's really just chokidar + some console messages. I'll try to extract more useful code, but not sure which features we would need
I'll check that out. The watch mode is just POC right now
Duplicated in what way? The
My 2 cents is it's just fluctuations, I'll keep an eye on that when I continue working on this |
Any ref to share? If the babel code doing this is not complex I'm fine, otherwise if it's full of annoying hacks for OSs, shells and FSs, I'd rather keep all this outside of Docusaurus |
Hmm, wasn't expecting the bundle to change, and it looks like minification has failed somewhere. I'll look into that Didn't read your inline comments, so ignore some of them. See here for |
4982a2d to
fe9a5f7
Compare
c986155 to
9094c89
Compare
9094c89 to
151b9c3
Compare
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Issue is actually in different place, its not related to minification but rather to how babel transforms code. current build preserves JSX syntax, but transforms imports and rest of the code to cjs than transforming code from jsx to for example: var _react = _interopRequireDefault(require("react"));
//. ....
return <article className="margin-vert--lg">
<_Link.default to={doc.permalink}>
<h2>{doc.title}</h2>
</_Link.default>
{doc.description && <p>{doc.description}</p>}
</article>;as for tests and translation issues, currently server requires that files exposed by packages are <_Link.default href={tag.allTagsPath}>
<_Translate.default id="theme.tags.tagsPageLink" description="The label of the link targeting the tag list page">
View All Tags
</_Translate.default>
</_Link.default>
i do like an idea of package that provide build utils :) |
Technically we should allow to use an alias too,
Not sure what you have in mind. I'd like to build a Babel plugin someday so that the translation runtime could self-erase at build time (considering all i18n strings are static), but not sure it's good timing as the frontend ecosystem is migrating to Rust without Babel 🤷♂️ What are the advantages of using a plugin for you? |
easier/uniform configuration, and this tool can be exposed for 3th party plugin developers |
Afaik we don't have any configuration for it and the goal is somehow to hide the fact that it's using Babel under the hood. We should be able to migrate to Rust or whatever without users having to know. Does it make sense? |
c19655d to
5ffef38
Compare
|
I've recently done a lot of build pipeline refactors that make it really neat and sorted out, even without this unified utility.
The only problem is they are a bit duplicated and scattered. The demand for a unified workflow without copy&pasting the long |

Motivation
Resolve #5564.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Used internally
TODOs
tscin addition to Babel)tsc --noEmitafterwards but better bundle it into the same script;theme-commonrelies on the output.d.tsfile for typingBlocking PRs