Skip to content

Neither default entry or browser is ready for webpack inclusion #5

@dcousineau

Description

@dcousineau

I just ran across a bug that isn't a high priority but I wanted to report it and ask what way you would prefer to proceed before opening a PR:

In my project I do import focusWithin from 'focus-within'; /* ... */ focusWithin(document); in my entry-point file. Doing so results in my vendors bundle including focus-within/index.js. I do not include the browser file manually in its own <script /> tag for two main reasons: existing build chain and performance.

A user with Safari 9 (this is why the bug isn't a high priority) visited my application an immediately errored out with: SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.

While my application handles the babel transformations required for our supported browsers list (which admittedly does not include Safari 9 but does convert all const/let to var still), as is standard convention we do not transform any node_modules as we expect them to be pre-compiled. We have resolve the issue by carving out an exception and passing focus-within through our babel transformation.

Looking at focus-within I think there are three possibilities for resolution going forward:

  1. Update the build config to transform the const/let into var in the index output(s), thereby producing a more strict ES5 compat build.
  2. Update the build config to leave a module.exports ... line so it becomes eligible for inclusion in common Webpack flows
  3. Ignore this case entirely and provide instructions in the documentation on how to force babel processing for users like me.

I am unfamiliar with rollup (I poked around to see if I could open a PR quickly) but am more than happy to do the leg work on whichever of the above solutions you would prefer for your project.

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