Svg-sprite-loader: Syntax error on build with docker

Created on 9 Nov 2019  路  3Comments  路  Source: JetBrains/svg-sprite-loader

Do you want to request a feature, report a bug or ask a question?
Bug
What is the current behavior?
Outputed JS file from webpack build contains error in toString function

 __webpack_exports__["default"] = ({
      id: "user-usage",
      viewBox: "0 0 38 37",
      url: __webpack_require__.p + "sprite55a0357bc55085e0ec6fce02d56198ee.svg#user-usage",
      toString: function () {
        return t);his.url;
      }
    }

What is the expected behavior?

Proper JS output file.

Please tell us about your environment:

  • Node.js version: 10.13
  • webpack version: 4
  • svg-sprite-loader version: 4.1.6
  • OS type & version: Docker image node:10.13

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

This bug is present only when I try to build app inside docker container, on plain linux machine it works fine.

Workaround: Set esModule config option to false.
image

Most helpful comment

@deadstar2011 Try also setting esModule: false in config.

https://github.com/JetBrains/svg-sprite-loader#es-module

All 3 comments

Do you want to request a feature, report a bug or ask a question?
Bug
What is the current behavior?
Outputed JS file from webpack build contains error in toString function

 __webpack_exports__["default"] = ({
      id: "user-usage",
      viewBox: "0 0 38 37",
      url: __webpack_require__.p + "sprite55a0357bc55085e0ec6fce02d56198ee.svg#user-usage",
      toString: function () {
        return t);his.url;
      }
    }

What is the expected behavior?

If the current behavior is a bug, please provide the steps to reproduce, at least part of webpack config with loader configuration and piece of your code.
The best way is to create repo with minimal setup to demonstrate a problem (package.json, webpack config and your code).
It you don't want to create a repository - create a gist with multiple files

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

Please tell us about your environment:

  • Node.js version: 10.13
  • webpack version: 4
  • svg-sprite-loader version: 4.1.6
  • OS type & version: Docker image node:10.13

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

This bug is present only when I try to build app inside docker container, on plain linux machine it works fine.
image

Hi. did u find the way to fix it? i have similar problem:

ERROR in chunk common [initial] js/common.min.js /data/node_modules/babel-loader/lib/index.js??ref--5!/data/src/modules/header/index/index.js 2ae6a7272a7e141c17cf5ce51a84b06e Unexpected token (8:2) | return this.url; | } | ); } SyntaxError: /data/node_modules/babel-loader/lib/index.js??ref--5!/data/src/modules/header/index/index.js 2ae6a7272a7e141c17cf5ce51a84b06e Unexpected token (8:2) | return this.url; | } | ); } at Parser.pp$4.raise (/data/node_modules/acorn/dist/acorn.js:2825:15) at Parser.pp.unexpected (/data/node_modules/acorn/dist/acorn.js:689:10) at Parser.pp.expect (/data/node_modules/acorn/dist/acorn.js:683:28) at Parser.pp$3.parseObj (/data/node_modules/acorn/dist/acorn.js:2459:14) at Parser.pp$3.parseExprAtom (/data/node_modules/acorn/dist/acorn.js:2246:19) at Parser.pp$3.parseExprSubscripts (/data/node_modules/acorn/dist/acorn.js:2089:21) at Parser.pp$3.parseMaybeUnary (/data/node_modules/acorn/dist/acorn.js:2066:19) at Parser.pp$3.parseExprOps (/data/node_modules/acorn/dist/acorn.js:2010:21) at Parser.pp$3.parseMaybeConditional (/data/node_modules/acorn/dist/acorn.js:1993:21) at Parser.pp$3.parseMaybeAssign (/data/node_modules/acorn/dist/acorn.js:1968:21) at Parser.pp$3.parseParenAndDistinguishExpression (/data/node_modules/acorn/dist/acorn.js:2321:30) at Parser.pp$3.parseExprAtom (/data/node_modules/acorn/dist/acorn.js:2230:43) at Parser.pp$3.parseExprSubscripts (/data/node_modules/acorn/dist/acorn.js:2089:21) at Parser.pp$3.parseMaybeUnary (/data/node_modules/acorn/dist/acorn.js:2066:19) at Parser.pp$3.parseExprOps (/data/node_modules/acorn/dist/acorn.js:2010:21) at Parser.pp$3.parseMaybeConditional (/data/node_modules/acorn/dist/acorn.js:1993:21) at Parser.pp$3.parseMaybeAssign (/data/node_modules/acorn/dist/acorn.js:1968:21) at Parser.pp$1.parseVar (/data/node_modules/acorn/dist/acorn.js:1228:26) at Parser.pp$1.parseVarStatement (/data/node_modules/acorn/dist/acorn.js:1092:10) at Parser.pp$1.parseStatement (/data/node_modules/acorn/dist/acorn.js:842:19) at Parser.pp$1.parseTopLevel (/data/node_modules/acorn/dist/acorn.js:746:23) at Parser.parse (/data/node_modules/acorn/dist/acorn.js:553:17) at Function.parse (/data/node_modules/acorn/dist/acorn.js:576:37) at Function.parse (/data/node_modules/webpack/lib/Parser.js:2396:22) at ConcatenatedModule.source (/data/node_modules/webpack/lib/optimize/ConcatenatedModule.js:670:19) at ModuleTemplate.render (/data/node_modules/webpack/lib/ModuleTemplate.js:54:32) at /data/node_modules/webpack/lib/Template.js:233:28 at Array.map (<anonymous>) at Function.renderChunkModules (/data/node_modules/webpack/lib/Template.js:230:30) at JavascriptModulesPlugin.renderJavascript (/data/node_modules/webpack/lib/JavascriptModulesPlugin.js:159:34) at Object.render (/data/node_modules/webpack/lib/JavascriptModulesPlugin.js:107:14) at Compilation.createChunkAssets (/data/node_modules/webpack/lib/Compilation.js:2172:29) at /data/node_modules/webpack/lib/Compilation.js:1397:10 at AsyncSeriesHook.eval [as callAsync] (eval at create (/data/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1) at AsyncSeriesHook.lazyCompileHook (/data/node_modules/tapable/lib/Hook.js:154:20) at Compilation.seal (/data/node_modules/webpack/lib/Compilation.js:1342:27)
Unexpected ); then im using:
new SpriteLoaderPlugin()

with new SpriteLoaderPlugin({plainSprite: true}) its build fine inside docker container.

npm run build at host system work perfectly

I use node 12.13.0
npm 6.9.0
alpine linux 3.9
webpack 4.41.2
svg-sprite-loader 4.1.6
@yaegor @joearasin @geshido @vaclav @denofevil @kisenka

@deadstar2011 Try also setting esModule: false in config.

https://github.com/JetBrains/svg-sprite-loader#es-module

@Mighty683 thx very much! its save my day

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sqal picture sqal  路  4Comments

suamikim picture suamikim  路  5Comments

Bosch-Eli-Black picture Bosch-Eli-Black  路  6Comments

alxpsr picture alxpsr  路  4Comments

zecka picture zecka  路  4Comments