Skip to content

How to handle global when format is 'es'? #1665

@robhicks

Description

@robhicks

I have identified an Javascript library (incremental-dom) as both a global and external. I'm loading the library in a script tag.

When the rollup format is 'iife' the library in injected into the iife and everything works.

However when I use the 'es' format, the global is never referenced and the browser throws a type error:

Uncaught TypeError: Failed to resolve module specifier 'incremental-dom'

Here's my rollup.config.js file:

const path = require('path');
const root = process.cwd();
const string = require('rollup-plugin-string');
const superviews = require('rollup-plugin-superviews');

export default [
  {
    input: path.resolve(root, 'src', 'idx-admin-tab', 'component.js'),
    plugins: [
      superviews({include: 'src/**/*.html'}),
      string({include: ['src/**/*.css', 'src/**/*.svg']})
    ],
    globals: {'incremental-dom': 'IncrementalDOM'},
    external: ['incremental-dom'],
    output: {
      file: path.resolve(root, 'dist', 'idx-admin-tab.es.js'),
      format: 'es'
    }
  }
];

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