Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Smallest possible bundle size for Markdown #2730

Closed
stefandobre opened this issue Jul 10, 2020 · 3 comments
Closed

Smallest possible bundle size for Markdown #2730

stefandobre opened this issue Jul 10, 2020 · 3 comments
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities webpack-plugin

Comments

@stefandobre
Copy link

Hi there,

I'm trying to create the most minimal bundle possible for a simple markdown editor, with no extra features enabled.
Here's my configuration:

const path = require("path");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");

module.exports = {
	mode: 'production',
	entry: "./index.js",
	output: {
		path: path.resolve(__dirname, "dist"),
		filename: "[name].bundle.js",
	},
	module: {
		rules: [{
			test: /\.css$/,
			use: ["style-loader", "css-loader",],
		}, {
			test: /\.ttf$/,
			use: ['file-loader']
		}],
	},
	plugins: [
		new MonacoWebpackPlugin({
			languages: ["markdown"],
			features: [
				'!accessibilityHelp',
				'!bracketMatching',
				'!caretOperations',
				'!clipboard',
				'!codeAction',
				'!codelens',
				'!colorDetector',
				'!comment',
				'!contextmenu',
				'!coreCommands',
				'!cursorUndo',
				'!dnd',
				'!find',
				'!folding',
				'!fontZoom',
				'!format',
				'!gotoError',
				'!gotoLine',
				'!gotoSymbol',
				'!hover',
				'!iPadShowKeyboard',
				'!inPlaceReplace',
				'!inspectTokens',
				'!linesOperations',
				'!links',
				'!multicursor',
				'!parameterHints',
				'!quickCommand',
				'!quickOutline',
				'!referenceSearch',
				'!rename',
				'!smartSelect',
				'!snippets',
				'!suggest',
				'!toggleHighContrast',
				'!toggleTabFocusMode',
				'!transpose',
				'!wordHighlighter',
				'!wordOperations',
				'!wordPartOperations'
			]
		})
	]
};

My main.bundle.js comes out at 1.5mb which seems quite big. Is this the minimum size of the editor or is there any way to slim this down even further?

@alexdima
Copy link
Member

Currently, this is the minimum size. There are still some features which cannot be removed via these features, like e.g. the minimap or rulers, etc. If you don't use those, they still get packaged, due to how the core of the editor is architected. At one point, we might want to make even those core components removable, but as it is right now, this is the minimum you can get before gzipping.

@fabiospampinato
Copy link

I'm very much interested in this as well, not necessarily with regards to Markdown but more generally I'd like the editor to become more modular.

This is currently what my Monaco bundle looks like:

image

And there seem to be lots of stuff in it that I probably don't need, like:

  • find module: I'm going to reimplement that so I don't need the one Monaco comes with. Maybe some of it is needed for highlighting matches but surely "findWidget" sounds useless for me. Disabling it via the plugin didn't seem to have any effect.
  • rename module: that I disabled too but it still got bundled up.
  • list module: if that's used only for optional widgets (command palette, menu, autocomplete etc.) I don't need that one either.
  • codicons I don't need at all, for consistency with the rest of the app I'll need to replace those icons anyway.
  • menu module: I don't see nor need any menus from monaco.
  • quick input module: that seems to refer to the quick pick widget used for the palette, I don't need that one either.
  • diff editor: definitely don't need that.
  • there are probably other things I don't need that could be removed, but some may be too core to the editor to modularize away.

If making all or some of those modules disableable doesn't require too much familiarity with the codebase I'd be interested in volunteering some time to do that, if that's the case some pointers would could be very useful.

@alexdima alexdima transferred this issue from microsoft/monaco-editor-webpack-plugin Nov 5, 2021
@alexdima alexdima added webpack-plugin help wanted Issues identified as good community contribution opportunities labels Nov 5, 2021
@hediet hediet added the feature-request Request for new features or functionality label Dec 8, 2021
@hediet hediet self-assigned this Dec 8, 2021
@clarkmcc
Copy link

I am also interested in ways to optimize the bundle size by disabling unnecessary functionality. Is there any update on this? Right now it's doubling the bundle size of my app.

@microsoft microsoft locked and limited conversation to collaborators Mar 13, 2023
@hediet hediet converted this issue into discussion #3823 Mar 13, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities webpack-plugin
Projects
None yet
Development

No branches or pull requests

5 participants