bigcommerce / stencil-cli

BigCommerce Stencil emulator for local theme development
https://developer.bigcommerce.com/stencil-docs
BSD 4-Clause "Original" or "Old" License
103 stars 141 forks source link

path.startsWith is not a function #712

Open dmaurya-gea opened 3 years ago

dmaurya-gea commented 3 years ago

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 stencil-cli@2.1.1, 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.

ZackEnders commented 3 years ago

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:

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'))}}
dmaurya-gea commented 3 years ago

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?

dmaurya-gea commented 3 years ago

@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?

walidargh commented 3 years ago

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.

jairo-bc commented 3 years ago

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?

dmaurya-gea commented 3 years ago

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

jairo-bc commented 3 years ago

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