Skip to content

Mark 'lodash' module as external dependency in rollup.config #131

@stachu3478

Description

@stachu3478

I have gone in the problem where i have found a lot of unused bundled code (lodash) and found easy way to solve that.

As in Screeps the lodash module is included by default, i think it should not be bundled one more time. So changing:

// rollup.config.js
export default {
  input: "src/main.ts",
  output: {
    file: "dist/main.js",
    format: "cjs",
    sourcemap: true
  },

  plugins: [
    clear({ targets: ["dist"] }),
    resolve(),
    commonjs(),
    typescript({tsconfig: "./tsconfig.json"}),
    screeps({config: cfg, dryRun: cfg == null})
  ]
}
// UPDATE TO
// rollup.config.js
export default {
  input: "src/main.ts",
  output: {
    file: "dist/main.js",
    format: "cjs",
    sourcemap: true
  },
  external: ['lodash'],

  plugins: [
    clear({ targets: ["dist"] }),
    resolve(),
    commonjs(),
    typescript({tsconfig: "./tsconfig.json"}),
    screeps({config: cfg, dryRun: cfg == null})
  ]
}

... would save a lot of code bundled and improve smart bundling effect.
However, there might be an issue with incompatible lodash version so it is still only an option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions