Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Browser custom formatter for Immutable-js values.

License

NotificationsYou must be signed in to change notification settings

immutable-js/immutable-devtools

Repository files navigation

TheImmutable library is fantastic, but inspecting immutable collections in browser's Dev Tools is awkward. You only see the internal data structure, not the logical contents. For example, when inspecting the contents of an Immutable List, you'd really like to see the items in the list.

Chrome (v47+) and Firefox (116+) has support for custom "formatters". A formatter tells browser's Dev Tools how to display values in the Console, Scope list, etc. This means we can display Lists, Maps and other collections, in a much better way.

Essentially, it turns this:

Before

into:

After

This library provides a formatter and a browser extension to do just that.

Features

The library currently has formatters for:

  • List
  • Map &OrderedMap
  • Set &OrderedSet
  • Stack
  • Record
  • Range
  • Repeat (if you wish this, add 👍 to#22)
  • Seq — I do not have an idea how to display it. If you know,write it down into #23

Want something more?Write down your wishes!

Installation

Chrome v47+ / Firefox v116+

In Dev Tools, press F1 to load the Settings. Scroll down to the Console section and tick "Enable custom formatters".

Browser Extension

You can directly install the browser extension for Chrome or Firefox. It automatically installs the formatters when you open the DevTools.

Install in project

Then, in your project, install via npm:

npm install --save-dev @immutable/devtools

And enable with:

import*asImmutablefrom'immutable';importinstallDevToolsfrom'@immutable/devtools';installDevTools(Immutable);

Note: You probably only want this library for debug builds, so perhaps wrap withif (DEBUG) {...} or similar.

Using with webpack

You could usewebpack.DefinePlugin to create a condition that will be allowed to installimmutable-devtools in the debug build but unreachable in the production build:

// webpack.config.jsvarwebpack=require('webpack');module.exports={// ...plugins:[newwebpack.DefinePlugin({__DEV__:JSON.stringify(process.env.NODE_ENV!=='production'),}),],};

In your source you'd have something like this...

// index.jsimport*asImmutablefrom'immutable';importinstallDevToolsfrom'@immutable/devtools';if(__DEV__){installDevTools(immutable);}

And then by adding the-p shortcut to webpack for production mode which enables dead code elimination, the condition that requires immutable-devtools will be removed.

NODE_ENV=production webpack -p index.js

See#16 for more info.

Contributing

devtools

  1. Install yarn berry if you don't have it already
  2. Clone the project
  3. runyarn install
  4. runyarn run build on each file you change
  5. open theindex.html located in thepackages/devtools/demo directory and open the console.

Browser extension

  1. yarn install
  2. yarn build
  3. On Chrome:
    1. Open "chrome://extensions"
    2. Enable "Developer mode"
    3. Click "Load unpacked" and select the "packages/extension/extension" directory
  4. On Firefox:
    1. On your console, go to the/packages/extension/extension directory
    2. Runweb-ext run (you may need to installweb-ext)
  5. Open devtools settings and enable custom formatters
  6. Open "/packages/extensions/test-page/index.html" to check everything looks as expected.

Make sure to reload the extension after any changes.

Original projects

This projet is a fork ofandrewdavey/immutable-devtools byPavel Lang andAndrew Davey, andmattzeunert/immutable-object-formatter-extension byMatt Zeunert.

I tried to contact them via github and by mail, but I didn't get any answer. So I decided to fork it and maintain it on the immutable-js organization directly.

About

Browser custom formatter for Immutable-js values.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors10


[8]ページ先頭

©2009-2025 Movatter.jp