Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svg-baker-runtime uses ES6 code that needs to be transpiled #385

Closed
sastraxi opened this issue Mar 4, 2020 · 2 comments · May be fixed by navikt/engangsstonad#715
Closed

svg-baker-runtime uses ES6 code that needs to be transpiled #385

sastraxi opened this issue Mar 4, 2020 · 2 comments · May be fixed by navikt/engangsstonad#715

Comments

@sastraxi
Copy link

sastraxi commented Mar 4, 2020

Do you want to request a feature, report a bug or ask a question?

This is a bug.

What is the current behavior?

svg-baker-runtime contains ES6 code that needs to be transpiled to run on targets that do not support ES6.

What is the expected behavior?

svg-baker-runtime has been properly transpiled in a build step to ES5.

If this is a feature request, what is motivation or use case for changing the behavior?

Our application supports IE11, and we've had to add a manual transpilation step into our webpack config in order to make sure our final bundle contains fully backwards-compatible code. This is the only module that we have to do this for, and ideally this should be fixed upstream.

Please tell us about your environment:

  • Node.js version: v12.16.1
  • webpack version: 4.41.2
  • svg-sprite-loader version: 4.1.6
  • OS type & version: MacOS Catalina 10.15.2

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

The webpack rule (in our code) that fixes this and brings back support for IE11:

            ...
            test: /\.js$/,
            exclude: [
                /* don't transpile node_modules, except for svg-baker-runtime */
                /node_modules\/(?!svg-baker-runtime)/,
            ],
            ...
@sastraxi
Copy link
Author

sastraxi commented Mar 4, 2020

Just doing some more investigation here, and this has to do with how the code gets exported. I see now looking through the distribution that svg-baker-runtime/browser-sprite.js is properly transpiled, as expected. What works:

import BrowserSprite from 'svg-baker-runtime/browser-sprite'

What doesn't work:

import BrowserSprite from 'svg-baker-runtime'

It feels like this is because of main vs module:

  "main": "browser-sprite.js",
  "module": "src/browser-sprite.js",

Perhaps the trick here is to add "browser": "browser-sprite.js" as per webpack/webpack#5756 (comment)

@kisenka
Copy link
Contributor

kisenka commented Apr 12, 2020

Shipped in svg-sprite-loader@4.2.5, please check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants