npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fluentui/monaco-editor

v1.3.17

Published

Version of monaco-editor with configuration helpers and transformed CSS files

Downloads

2,218

Readme

@fluentui/monaco-editor

Version of monaco-editor with the CSS files transformed to JS which can be loaded onto the page using @microsoft/load-themed-styles. Also includes some Webpack configuration helpers.

Package contents

  • esm/*: Copy of monaco-editor/esm/* but with the CSS files transformed. (This package doesn't include the AMD variant since it has a built-in CSS loader.)
  • scripts/addMonacoWebpackConfig.js: Add Monaco-related webpack configuration
  • lib/configureEnvironment.js: Set up MonacoEnvironment runtime config

How to use with Webpack

1. Webpack configuration

In your webpack.config.js, call the addMonacoWebpackConfig helper to add Monaco-related configuration (note that it returns a new configuration object):

const { addMonacoWebpackConfig } = require('@fluentui/monaco-editor/scripts/addMonacoWebpackConfig');

// Somewhere in this file, call:
config = addMonacoWebpackConfig(originalConfig, options);

Parameters:

  • config (webpack.Configuration): Your configuration object. Its entry must be an object (not an array or function), and the output.globalObject setting (if any) will be ignored.
  • options (object, optional):
    • outDir (string, optional): output directory where font files should be copied (requires copy-webpack-plugin to be installed)
    • includeAllLanguages (boolean, optional):
    • false (default): Imports for @fluentui/monaco-editor will be remapped to @fluentui/monaco-editor/lib/monacoCoreBundle, which includes only core editor features and TypeScript language features. Entry configs will be added for the main editor worker (editor.worker.js) and TS worker (ts.worker.js) but not other languages.
    • true: Imports for @fluentui/monaco-editor will be remapped to @fluentui/monaco-editor/lib/monacoBundle, which includes all language contributions. Also, entry configs will be added for CSS/HTML/JSON workers in addition to TS.

2. Runtime configuration

This project provides two options for setting up global Monaco configuration at runtime. The options are outlined below, but both involve a config object with the following properties:

  • baseUrl (string): CDN path or other path where built files are served from. (. is typical for local serve builds and other non-CDN scenarios.)
  • useMinified (boolean, optional): Whether to use the .min versions of the files. (Assumes you have an additional "production mode" webpack config which generates .min versions of all entry entries.)
  • crossDomain (boolean, optional): Whether to use a configuration variant which works when this script lives on a different domain than the core Monaco scripts.

Option A: Manual

In a root file for your project, import and call the configuration helper manually:

import { configureEnvironment } from '@fluentui/monaco-editor/lib/configureEnvironment';

configureEnvironment(config);

This lightweight helper sets up the global MonacoEnvironment required for Monaco to load the worker files generated by the webpack config (it doesn't import any actual Monaco files). Its config parameter is the simple configuration object described above.

Option B: Automatic using global

Somewhere in a root file for your project (the Fluent UI React projects do this in index.html), define a global variable MonacoConfig with the properties described above. Basic example:

window.MonacoConfig = {
  baseUrl: '.',
  useMinified: false,
};

Then the first time you import @fluentui/monaco-editor, it will automatically call configureEnvironment with the global object.

(This works because the Webpack config remaps @fluentui/monaco-editor imports to point to either lib/monacoBundle or lib/monacoCoreBundle, both of which re-export Monaco things and call configureEnvironment as a side effect.)

3. Using the editor

When you're ready to use the editor, import as follows:

import * as monaco from '@fluentui/monaco-editor';

See the Monaco documentation for further usage instructions.