LLazyEmail / markdown-to-email

GNU General Public License v3.0
8 stars 13 forks source link

fix and enable eslint for rollup #1012

Closed github-actions[bot] closed 2 years ago

github-actions[bot] commented 2 years ago

https://rollupjs.org/guide/en#external-e-external

https://github.com/LLazyEmail/markdown-to-email/blob/81ac545bab63357eed7d8e5668421e36dbc71366/src/domain/plainjs-template/typography/Typography/rollup.config.js#L48


import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
// import json from "rollup-plugin-json";
import builtins from "rollup-plugin-node-builtins";
import babel from "@rollup/plugin-babel";
// import notify from "rollup-plugin-notify";
import pkg from "./package.json";
import globals from "rollup-plugin-node-globals";
import includePaths from "rollup-plugin-includepaths";

// import eslint from "rollup-plugin-eslint";

// not all files you want to resolve are .js files
// Default: [ '.mjs', '.js', '.json', '.node' ]
const extensions = [
  ".js",
  //".json"
];

const name = "newsletterLayoutsTypographyPlainJS";

// packages that should be treated as external dependencies, not bundled
// e.g. ['axios']
const external = [
    // "fs", "path", "uuid"
];

const includePathOptions = {
  include: {},
  paths: ["src"],
  external: [],
  extensions
};

// list of plugins used during building process
const plugins = () => [
  // Allows node_modules resolution
  resolve({
    extensions,

    // the fields to scan in a package.json to determine the entry point
    // if this list contains "browser", overrides specified in "pkg.browser"
    // will be used
    mainFields: ["module", "main", "browser"] // Default: ['module', 'main']
  }),

  // Allows verification of entry point and all imported files with ESLint.
  // @TODO fix and enable eslint for rollup
  // eslint({
  //   /* your options */
  //   fix:true,
  //   throwOnWarning:true,
  //   throwOnError:true

  // }),

  // Allow bundling cjs modules. Rollup doesn't understand cjs
  commonjs({
    ignore: ["conditional-runtime-dependency"]
  }),

  // use Babel to compile TypeScript/JavaScript files to ES5
  babel({
    extensions,
    include: ["src/*"],
    // ignore node_modules/ in transpilation process
    exclude: [
      "node_modules/**",
       // "/src/data/__tests__"
     ],
    // ignore .babelrc (if defined) and use options defined here
    // babelrc: false,
    // use recommended babel-preset-env without es modules enabled
    // and with possibility to set custom targets e.g. { node: '8' }
    // presets: [['env', { modules: false, targets }]],
    // solve a problem with spread operator transpilation https://github.com/rollup/rollup/issues/281
    // plugins: ['babel-plugin-transform-object-rest-spread'],
    // removes comments from output
    comments: false,
    // babelHelpers: 'runtime'
  }),

  // Allow Rollup to import data from JSON file
  // json()
  // json({
  //   include: "src/data/**",
  //
  //   // for tree-shaking, properties will be declared as
  //   // variables, using either `var` or `const`
  //   preferConst: true,
  //
  //   // generate a named export for every property of the JSON object
  //   namedExports: true // Default: true
  // }),
  // Displays rollup errors as system notifications
  includePaths(includePathOptions),
  // notify(),
  globals(),
  builtins()

  // remove flow annotations from output
  // flow(),

  // copy Flow definitions from source to destination directory
  // copy({
  //   files: ['src/*.flow'],
  //   dest: 'dist',
  // }),
];

// example for adding plugin for env only
// if(process.env.NODE_ENV == "production") {
//   console.log("[config] In production environment - minifying JS");
//   plugins.push(terser({
//     numWorkers: os.cpus().length,
//     compress: {
//       ecma: 6
//     }
//   }));
// }

export default {
  // source file / entrypoint
  input: "src/index.js",
  external,
  plugins: plugins(),
  // output configuration
  output: [
    {
      // output file location
      file: pkg.main,
      // format of generated JS file, also: esm, and others are available
      format: "cjs"
    },
    {
      // output file location
      file: pkg.module,
      // format of generated JS file, also: esm, and others are available
      format: "es",
      // format: 'esm',
      // add sourcemaps
      sourcemap: true
    },
    {
      // output file location
      file: pkg.browser,
      // format of generated JS file, also: esm, and others are available
      format: "iife",
      // name visible for other scripts
      name,

      // https://rollupjs.org/guide/en#output-globals-g-globals
      globals: {
        path: "path"
      }
    }
  ]

  // Specify here external modules which you don't want to include in your bundle (for instance: 'lodash', 'moment' etc.)
  // https://rollupjs.org/guide/en#external-e-external

  // build es modules or commonjs
};
github-actions[bot] commented 2 years ago

Closed in 8a0d723f73f432a6029f371d1e7180d5ea3bf3a7