stencil-cli icon indicating copy to clipboard operation
stencil-cli copied to clipboard

path.startsWith is not a function

Open deepak-aupchaarik opened this issue 4 years ago • 7 comments

Expected behavior

Server started using stencil start should serve the local theme

Actual behavior

Nothing renders on the browser and an error is output on the terminal path.startsWith is not a function

Steps to reproduce behavior

Execute stencil start -o in the terminal in the theme directory.

The theme preview works fine for [email protected], error occurs in 3.0.3 and 3.2.0 that I have tried.

Edit

The preview works if you change the template engine from Handlebars version 4 to Handlebars version 3.

"template_engine": "handlebars_v4" -> "template_engine": "handlebars_v3"

Doesn't seem like a solution.

deepak-aupchaarik avatar Apr 30 '21 06:04 deepak-aupchaarik

Do you have any handlebars cdn and concat helpers being used together in your stencil theme? I had this issue and was able to resolve it by updating all of my cdn helpers that also use concat. The concat helper creates a SafeString object and it looks like the cdn helper in handlebars_v4 doesn't like it.

Example:

<img src="{{cdn (concat (concat 'img/payment-methods/' brand) '.svg')}}">

The cdn call in the example above is trying to use a SafeString object as the url:

SafeString { string: 'img/payment-methods/visa.svg' }

I was able to fix this by wrapping the concat helpers with a get helper:

{{cdn (get 'string' (concat (concat 'img/payment-methods/' brand) '.svg'))}}

ZackEnders avatar May 18 '21 22:05 ZackEnders

Do you have any handlebars cdn and concat helpers being used together in your stencil theme? I had this issue and was able to resolve it by updating all of my cdn helpers that also use concat. The concat helper creates a SafeString object and it looks like the cdn helper in handlebars_v4 doesn't like it.

There are a bunch of such usages in the theme. All of them are in the customizations. I'll make the updates and see if it works for me as well.

This is crazy random to me though. Is there any v3 - v4 migration guide?

deepak-aupchaarik avatar May 21 '21 10:05 deepak-aupchaarik

@ZackEnders an update. I removed all the instances of the cdn and concat helpers and replaced with what you suggested, still getting the error.

Are there any other things that v4 doesn't like?

deepak-aupchaarik avatar May 21 '21 12:05 deepak-aupchaarik

It seems like the issue is related to the @bigcommerce/stencil-paper package, specifically version ^3.0.0-rc.30 which comes with the cli by default. I manually switched that to 3.0.0-rc.29 and it seems to work for now, but I haven't done rigorous testing so I don't know what else will break.

walidargh avatar May 26 '21 09:05 walidargh

Hi @dmaurya-gea! Where you able to proceed with your issue?

If no, could you help me reproducing it by providing some information about your theme? Which theme and version are you using?

jairo-bc avatar Jun 30 '21 11:06 jairo-bc

Hi @dmaurya-gea! Where you able to proceed with your issue?

If no, could you help me reproducing it by providing some information about your theme? Which theme and version are you using?

Hi @jairo-bc. No the issue was not resolved.

I had to make do with changing the handlebars engine to v3 during local preview, and change it to v4 before push.

I tried it with different versions, all versions 3.x.x had this problem. Not with the latest 2.x.x

deepak-aupchaarik avatar Jul 06 '21 12:07 deepak-aupchaarik

@dmaurya-gea Are you on the custom theme? Or is it cornerstone?

jairo-bc avatar Jul 06 '21 16:07 jairo-bc