• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const resolve = 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.js',
9  output: {
10    file: 'dist/index.js',
11    format: 'cjs',
12    sourcemap: false,
13  },
14  external: [
15    'stream',
16    'path',
17    'module',
18    'util',
19    'tty',
20    'os',
21    'fs',
22    'fsevents',
23    'events',
24    'assert',
25  ],
26  plugins: [
27    {
28      name: 'brute-replace',
29      transform(code, id) {
30        const normID = id.replace(__dirname, '').replace(/\\+/g, '/');
31        if (normID === '/node_modules/concat-stream/index.js') {
32          return code.replace('\'readable-stream\'', '\'stream\'');
33        }
34        if (normID === '/node_modules/unified-args/lib/options.js') {
35          return code.replace('\'./schema\'', '\'./schema.json\'');
36        }
37        if (normID === '/node_modules/chokidar/lib/fsevents-handler.js') {
38          return code.replace(
39            'fsevents = require(\'fsevents\');', 'fsevents = undefined;'
40          );
41        }
42      }
43    },
44    json({
45      preferConst: true
46    }),
47    resolve(), // tells Rollup how to find date-fns in node_modules
48    commonjs(), // Converts date-fns to ES modules
49    {
50      name: 'banner',
51      renderChunk(code) {
52        const banner = '// Don\'t change this file manually,\n' +
53          '// it is generated from tools/node-lint-md-cli-rollup';
54        return code.replace('\'use strict\';', '\'use strict\';\n\n' + banner);
55      }
56    },
57  ]
58};
59