-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[WIP] rollup and ESM export #1858
Conversation
Some advantages to remove aliases: - Better integration with code editors (VSCode in mind) - Easier to move to another bundler
Deploy preview for netlify-cms-www ready! Built with commit 9292cb5 |
Deploy preview for cms-demo ready! Built with commit 9292cb5 |
Current problems:
My first wish at this time is to receive your opinion about this implementation and knowing if I could go further. Thanks for your attention! |
74080c9
to
cd1052a
Compare
c894742
to
2d7f248
Compare
2d7f248
to
63a2e23
Compare
First of all, thank you! This is awesome work in a critical area of need for the project!! 👏👏 Whenever a massive changeset comes through, it's good to slim down where we can. I'd really like to see removal of Checking it out locally now. |
This reverts commit 376ded3. # Conflicts: # packages/netlify-cms-core/babel.config.js # packages/netlify-cms-core/src/reducers/auth.js
For an unkonwn reason, some aliased import does not work in Rollup like Webpack. For example, `import ‘Redux’` results in `require(‘./redux/index.js’)` in the ESM bundle and it is not bundled.
Hi @erquhart I agree that removal of - import { getAsset } from 'Reducers';
+ import { getAsset } from 'Reducers/index'; Otherwise, rollup output contains: import { getAsset } from "./redux/index"; In that case, Rollup does not find the module and left the import into the bundle... I tried to solves aliases from Rollup with plugin:
I need to investigate more about it but... I am convicted that aliases are not necessary 😬 |
I've restructured this entire codebase twice in the last twelve months; relative imports were a ridiculous pain to deal with. Let's see if we can find a way to make aliases work. |
This comment by Rich Harris is right on - adding |
I'm also fine with just importing using |
Yep okay let's keep the |
I remove the |
Off today but I'll dig into this tomorrow 👍 |
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.
Just a couple of small changes (plus merge conflict resolution) and this is good to merge - awesome work @LoicMahieu, this is a clutch PR!! 👏👏
const pkg = require('./package.json'); | ||
const { plugins } = require('../../scripts/webpack'); | ||
const coreWebpackConfig = require('../netlify-cms-core/webpack.config.js'); | ||
const pkg = require(path.join(process.cwd(), 'package.json')); |
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'd opt for __dirname
instead of process.cwd()
here, in case the cli is run from somewhere other than root.
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.
pkg
here should be the specific package, not the root. The logic does not change from the current version.
Update: looks like our UMD build went from ~2MB to ~4MB. We'll have to find a way to address that before merging. |
Just curious what was a pain with relative paths? In my experience it's the other way around 😛 |
When you move a file to a different level of nesting, all relative imports break. When you move 80 files to a different level of nesting, your sanity breaks. Sent with GitHawk |
@LoicMahieu Do you have enough time to get this through to the finish line? If not I could have a look and try to fix the remaining stuff 😄 |
GitHub needs a 💪reaction. You're killing it @alexandernanberg. |
Hi @alexandernanberg
|
* official/master: (42 commits) chore: improve publish scripts Publish chore: test before publishing chore(netlify-cms-core): upgrade react-dnd to 7.x (decaporg#1922) chore(netlify-cms-widget-text): upgrade to react-textarea-autosize 7.x (decaporg#1921) chore(netlify-cms-core): upgrade to react-waypoint 8.x (decaporg#1920) fix(backend): use singular label in custom commit message (decaporg#1917) docs: add GAE-specific oAuth client (decaporg#1918) fix(netlify-cms-widget-text): set correct font family (decaporg#1916) chore(netlify-cms-core): upgrade redux and related dependencies (decaporg#1914) chore(dependencies): bump npm-run-all (decaporg#1913) fix(netlify-cms-core): fix identifier field validation (decaporg#1907) docs: improve widget custom validation sample (decaporg#1911) improvement(backends): changes for registerBackend compatibility (decaporg#1880) fix(netlify-cms-core): fix prop-types warnings (decaporg#1906) fix(a11y): correct label "for" references to fields (decaporg#1904) improvement(netlify-cms-core): wrap navigations in lists for better a11y (decaporg#1903) fix(netlify-cms-widget-markdown): add missing border radius on toolbar (decaporg#1905) fix(netlify-cms-core): remove double focusable elements on profile menu button (decaporg#1900) fix(config): remove identifier field validation (decaporg#1882) ...
* official/master: update release ticker Publish feat: add cloudinary support (decaporg#1932) fix(netlify-cms-core): duplicate key warning (decaporg#1930) Update image.md (decaporg#1923) chore(netlify-cms-core): upgrade react-frame-component to 4.x (decaporg#1925) chore(netlify-cms-core): upgrade gray-matter to 4.x (decaporg#1924) feat(netlify-cms-widget-select): add support for multiple selection (decaporg#1901) # Conflicts: # packages/netlify-cms-widget-select/package.json # packages/netlify-cms/src/media-libraries.js
entry: './index.js', | ||
mode: isProduction ? 'production' : 'development', | ||
context: path.join(__dirname, 'dist'), | ||
entry: './netlify-cms.esm.js', |
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.
Is this really correct? I think webpack needs the raw source file. This could explain the large UMD bundle as well
Closing this as abandoned, but please reopen if you'd like to move this forward. |
1. Summary
It's a quite big PR for my first contribution. I'm sorry, I would have preferred to find something easier to do at first. I tried something simple, it's in the garage... I could not develop it on top of the actual build system due to performance.
There is some problem in the current build implementation:
netlify-cms
) produces a UMD build which, I think, is never used by anyone. (Maybe there is a case for import manually a widget or something else ?)netlify-cms
module have an "hacky" import. Since we don't want to bundle once again a UMD bundle from other UMD bundles, it imports directly/src
.netlify-cms
have a bunch ofdependencies
that are not used in production, since every dependencies are bundled.Important changes:
rollup
instead ofwebpack
for all modules (exceptnetlify-cms
). It only produces aESM
build.netlify-cms
still build an UMD package from the ESM with webpack.rollup-plugin-react-svg
for SVG to React transformation. It does not seem to change much.module-resolver
. It was initially proposed in PR netlify-cms-core: remove alias andmodule-resolver
#1847. I did that because I found difficulties to implement it with Rollup and...... since I don't like it much... 😚 But it should be possible to use it. If you want to see them come back, yell at me and I'll do what's necessary.Advantages:
Fixes issues:
Breaking changes
netlify-cms
) will not exports amain
file but only anmodule
file.It does not introduce any breaking change on
netlify-cms
.I don't know if they are used separately/directly.
2. Test plan
CI should confirm that build works. Tested on my machine, build and develop works well!
3. A picture of a cute animal
As big as this PR!