Open nikolayandr opened 7 years ago
Hi, can you please elaborate more on the issue that you are getting and what static site generator you use so we can reproduce?
1) Used server is jekyll
2) Before launching all files combined into one file app.js using tool browserify
3) When server is launched, it processes file app.js. And as the file includes all files from your sdk which use this pattern for preparing paths to resources, as a result this placeholders are replaced on value projectId. For example before was: var pathCartBase = '/hybris/cart/v1/{{projectId}}/carts'
after became var pathCartBase = '/hybris/cart/v1/projectId/carts';
As a result base path cannot be prepared when a request helper tries to make request
For solving this problem I need to customize and keep your library out of node modules, because this is not possible to change a pattern which should be used by jekyll
I would suggest if we change things here, then we should use template literals. I'm fine bringing such a change into master, if you can send us a PR.
Maybe this is not the best time for adding this feature using template literals, because if it would be done, users who use your SDK have to update their javascript tools to the latest version for supporting ES6. For example popular uglify tool is not able to parse source code which contains template literals, I got the next error:
WARN: ERROR: Unexpected character '`' [-:3715,19]
../node_modules/uglify-js2/lib/parse.js:199
throw new JS_Parse_Error(message, line, col, pos);
^
Error
at new JS_Parse_Error (../node_modules/uglify-js2/lib/parse.js:185:18)
at js_error (../node_modules/uglify-js2/lib/parse.js:199:11)
at parse_error (../node_modules/uglify-js2/lib/parse.js:291:9)
at Object.next_token [as input] (/mnt/ssd/expbag5/bag/front/node_modules/uglify-js2/lib/parse.js:523:9)
at next (../node_modules/uglify-js2/lib/parse.js:616:25)
at vardefs (../node_modules/uglify-js2/lib/parse.js:1015:48)
at var_ (../node_modules/uglify-js2/lib/parse.js:1028:27)
at ../node_modules/uglify-js2/lib/parse.js:788:30
at ../node_modules/uglify-js2/lib/parse.js:677:24
at block_ (../node_modules/uglify-js2/lib/parse.js:935:20)
And there is other reason which makes a difficult to use template literals, currently the place, where base path is declared, does not contain project Id but for using literals templates you have to declare this template in the same place where variables are defined, in our case it is projectId
.
Hi. Placeholder {{projectId}} conflicts with some static site generators which use this pattern for replacing placeholders by variable values. Can you change this pattern on some other, for example on [[projectId]]?