• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const { nodeResolve } = require('@rollup/plugin-node-resolve');
4const commonjs = require('@rollup/plugin-commonjs');
5const json = require('@rollup/plugin-json');
6
7module.exports = {
8  input: 'src/cli-entry.mjs',
9  output: {
10    file: 'dist/index.mjs',
11    format: 'es',
12    sourcemap: false,
13    exports: 'none',
14  },
15  external: [
16    'node:events',
17    'node:fs',
18    'node:path',
19    'node:process',
20    'node:stream',
21    'node:url',
22  ],
23  plugins: [
24    {
25      name: 'brute-replace',
26      transform(code, id) {
27        const normID = id.replace(__dirname, '').replace(/\\+/g, '/');
28        if (normID === '/node_modules/concat-stream/index.js') {
29          return code.replace('\'readable-stream\'', '\'stream\'');
30        }
31        if (normID === '/node_modules/unified-args/lib/options.js') {
32          return code.replace('\'./schema\'', '\'./schema.json\'');
33        }
34        if (normID === '/node_modules/chokidar/lib/fsevents-handler.js') {
35          return code.replace(
36            'fsevents = require(\'fsevents\');', 'fsevents = undefined;'
37          );
38        }
39        // Remove circular dependency in glob that messes up rollup
40        return code.replace("var Glob = require('./glob.js').Glob", '');
41      }
42    },
43    json({
44      preferConst: true
45    }),
46    nodeResolve({ exportConditions: ['node'] }),
47    commonjs(),
48    {
49      name: 'banner',
50      renderChunk(code) {
51        const banner = '// Don\'t change this file manually,\n' +
52          '// it is generated from tools/node-lint-md-cli-rollup';
53        return code.replace('\'use strict\';', '\'use strict\';\n\n' + banner);
54      }
55    },
56  ]
57};
58