Skip to content

Using injectr with babel #23

Description

@sheepsteak

I have injectr.onload set up to run files through babel like so:

injectr.onload = (file, content) => {
  return require('babel').transform(content, {
    filename: file,
    optional: ['runtime', 'es7.classProperties', 'es7.objectRestSpread']
  }).code;
};

This works but it seems like the polyfilled methods such as [1, 2, 3].includes(2) have to be written as Array.includes([1, 2, 3], 2) instead. Even if I prepend the file content with require('babel/polyfill') I get the same result.

Do you know why the polyfilled methods wouldn't be usable with an injected module?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions