ondras / rollup-plugin-graph

Generates module dependencies graph, using the DOT language.
31 stars 2 forks source link

Failing with configuration from README.md #2

Open lukasholzer opened 5 years ago

lukasholzer commented 5 years ago

Rollup fails with your intial configuration

Error Log

yarn clean && rollup -c | dot -Tpng > graph.png
$ rm -rf lib coverage
/bin/sh: dot: command not found

src/index.ts → lib/index.cjs.js...
[!] (Plugin at pos 4 plugin) TypeError: data.bundle.modules.map is not a function
TypeError: data.bundle.modules.map is not a function
    at Object.ongenerate (/Users/lukas.holzer/Sites/ng-sketch/node_modules/rollup-plugin-graph/index.js:39:34)
    at /Users/lukas.holzer/Sites/ng-sketch/node_modules/rollup/dist/rollup.js:20962:25
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:236:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)

error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

rollup.config.js


import typescript from 'rollup-plugin-typescript2';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json'
import pkg from './package.json';
const graph = require('rollup-plugin-graph');

const graphOptions = { prune: true };
const NODE_NATIVES = ['path', 'fs', 'os', 'buffer', 'crypto', 'util', 'child_process', 'perf_hooks'];
const DEPENDENCIES = Object.keys(pkg.dependencies);

export default [
  {
    input: 'src/index.ts',
    output: [
      {
        name: 'helpers',
        file: pkg.main,
        format: 'cjs',
        sourcemaps: true,
      },
    ],
    external: [
      ...NODE_NATIVES,
      ...DEPENDENCIES,
    ],
    plugins: [
      json(),
      typescript({ tsconfig: './tsconfig.json', useTsconfigDeclarationDir: true, }),
      resolve(), // so Rollup can find `ms`
      commonjs(), // so Rollup can convert `ms` to an ES module
      graph(graphOptions),
    ]
  },
]
ondras commented 5 years ago

@lukasholzer please, what rollup version are you using? (npm ls | grep rollup)

lukasholzer commented 5 years ago

rollup version 0.67.3

ondras commented 5 years ago

Looks like some breaking rollup API change. This seems to be the recommended way now: https://rollupjs.org/guide/en#generatebundle

I will fix this soon.

ondras commented 5 years ago

Turns out rollup is no longer providing the necessary data to the plugin. Filed an issue: https://github.com/rollup/rollup/issues/2578

ondras commented 5 years ago

Hi @lukasholzer,

I just published a new version (2.0.0) that should work with the very recent 1.0.0 rollup. Please try and confirm :)

y-nk commented 5 years ago

@ondras could you also provide a dummy png as demoed output ?

ondras commented 5 years ago

Great idea, @y-nk ! I added a sample image and a description to the README.