Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Plugin class names missing from --inspect output #328

Closed
edmorley opened this issue Sep 22, 2017 · 11 comments
Closed

Plugin class names missing from --inspect output #328

edmorley opened this issue Sep 22, 2017 · 11 comments
Assignees
Milestone

Comments

@edmorley
Copy link
Member

Currently the output when using --inspect includes a plugins property, which contains an array of plugin options but not the actual name of the plugin to which the options belong.

For example:

  plugins: [
    {
      keys: [
        'NODE_ENV'
      ],
      defaultValues: {}
    },
    {
      options: {
        template: 'ui/index.html',
        filename: 'index.html',
        hash: false,
        inject: false,
        compile: true,
        favicon: false,
        minify: {
          useShortDoctype: true,
          keepClosingSlash: true,
          collapseWhitespace: true,
          preserveLineBreaks: true
        },
        cache: true,
        showErrors: true,
        chunks: 'all',
        excludeChunks: [],
        title: 'Webpack App',
        xhtml: true,
        appMountId: 'root',
        mobile: true
      }
    },

To work out the mapping of plugins to options, I have to cross-reference against the output from neutrino.config.toConfig():

  plugins: 
   [ EnvironmentPlugin { keys: [Array], defaultValues: {} },
     HtmlWebpackPlugin { options: [Object] },

This is using neutrino 6.2.0 and webpack-chain 3.3.0 with node 8.5.0.

@edmorley edmorley added the core label Sep 22, 2017
@eliperelman
Copy link
Member

The output of --inspect is essentially the config that will be passed to webpack, but sorted and formatted. Webpack doesn't accept this config with named output, it doesn't match its schema.

Maybe we can change --inspect to also allow viewing an object form of the webpack-chain config, e.g. --inspect named? Or --inspect-named?

@edmorley
Copy link
Member Author

edmorley commented Sep 25, 2017

Yeah I understand it's not meant to be passed to webpack, that's not what I want to use it for.

The bug here is that the current serialised representation is incomplete -- it omits key information (the plugin names) to be able to understand the current configuration (eg when reviewing a PR that changes a project's Neutrino config, and diffing the --inspect output before/after).

@eliperelman
Copy link
Member

From --help for --inspect:

Output a string representation of the configuration used by Neutrino and exit

You're right; this statement makes it sound like we are giving the Neutrino configuration and not the Webpack configuration. Switching it to the Neutrino config would be a breaking change. We can either fix the wording of the help to reference webpack, or change the output. Both outputs are useful, so we need a way to see both.

@edmorley
Copy link
Member Author

edmorley commented Sep 25, 2017

I think we might still be miss-understanding each other?

I don't really mind whether the output is technically neutrino config or webpack config, all I would like is for the output to include as much debugging information as possible. However at the moment names of the plugins aren't specified anywhere.

From the OP above:

  plugins: [
    {
      keys: [
        'NODE_ENV'
      ],
      defaultValues: {}
    },

Now whilst I can guess that these plugin options are for the EnvironmentPlugin, that's not stated explicitly, and instead could be for a hypothetical DeleteEnvironmentPlugin. Without knowing the plugin name, displaying the options is much less useful.

@edmorley
Copy link
Member Author

Though as a separate issue/feature request, having a way to view both the Neutrino config and webpack configs would be useful :-)

@eliperelman
Copy link
Member

I think I understand: right now you are seeing the webpack config, and you want the Neutrino config so you can see the names of entities.

@edmorley
Copy link
Member Author

I think I see where the confusion is coming from - surely the webpack config has to include the plugin names at some point? (Yes passed as objects, but that could still be serialised?)

@edmorley
Copy link
Member Author

And just in case, another clarification: By plugin names, I'm not meaning the identifier (eg style) given to plugins in Neutrino, I'm meaning the actual module/class name of the webpack plugin.

@edmorley edmorley changed the title Plugin names missing from --inspect output Plugin class names missing from --inspect output Oct 6, 2017
@eliperelman
Copy link
Member

eliperelman commented Oct 30, 2017

Note that this would be a breaking change, since switching the format of the inspection would break uses of diff when comparing to before and after this change: git diff --no-index a.inspection b.inspection.

@edmorley
Copy link
Member Author

I guess what I'm really after is an equivalent to create-react-app's "eject" feature.

edmorley added a commit that referenced this issue Jun 5, 2018
This take advantage of the new webpack-chain `toString()` added in
neutrinojs/webpack-chain#53.

The output from `neutrino --inspect` now lists the correct plugin
declarations and arguments, annotates plugins/loaders with hints
about how to reference them in a custom Neutrino config, and supports
using `__expression` to override the stringified output when needed.

The usage of `deep-sort-object` has been removed since it breaks the
new `toString()` comment annotations, and really if sorted output is
considered important, it should be handled by webpack-chain itself.

Fixes #328.
Refs #96.
@edmorley edmorley added this to the v9 milestone Jun 7, 2018
@edmorley edmorley self-assigned this Jun 7, 2018
edmorley added a commit that referenced this issue Jun 7, 2018
This backports #928 to `release/v8` under a new argument name, to
prevent it from being a breaking change. This will allow Neutrino 8
users to benefit from the stringifed config improvements sooner, as
well as providing a way to compare v8 and v9 configurations.

I've not backported the eslint `formatter.__expression` change, since
it would require a fair amount of refactoring, increasing risk for
little benefit.

Fixes #328 for `release/v8`.
@edmorley
Copy link
Member Author

edmorley commented Jun 28, 2018

v8.3.0 has just been released, which backports the upcoming Neutrino 9's improved --inspect feature, as --inspect-new.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants