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

[Documentation] Engine configuration fileExtension vs extension #1480

Closed
StfBauer opened this issue Feb 3, 2023 · 6 comments · Fixed by #1489
Closed

[Documentation] Engine configuration fileExtension vs extension #1480

StfBauer opened this issue Feb 3, 2023 · 6 comments · Fixed by #1489
Assignees
Labels

Comments

@StfBauer
Copy link
Contributor

StfBauer commented Feb 3, 2023

I use Pattern Lab Node v6.0.1 on Windows | Mac | Linux, with Node v16.15.1, using a Vanilla Edition with a little bit of gulp flavoured on top.

I recently upgrade to version 6.0.1 everything works as expected but I got an error message that the engine is not configured correctly. The engine configuration looked as follows:

{
  "engines": {
    "handlebars": {
      "package": "@pattern-lab/engine-handlebars",
      "extensions": [
        "handlebars",
        "hbs"
      ],
      "extend": "helpers/hbs/*.js"
    }
  }
}

This is according to the documentation: Engine
However, I created a new project based on version 6.0.0.

The configuration in 6.0.0 looks as followed:

{
  "engines": {
    "handlebars": {
      "package": "@pattern-lab/engine-handlebars",
      "fileExtensions": [
        "handlebars",
        "hbs"
      ],
      "extend": "helpers/hbs/*.js"
    }
  }
}

After I modified my configuration to "fileExtension" instead of "extension", the error message was not showing up anymore. So the question is now. Is the documentation outdated, which it seems to be, or an issue in pattern lab that got introduced in v6.0.1

@JosefBredereck
Copy link
Contributor

I'm afraid none of the above is correct.
I wonder that there is an error message popping up because we do absolutely nothing with the given settings at the moment.
For most engines we, we only use extent, noting more.

I think the initial intention of the creator of that code was to allow the user to override the default fileExtensions.
I will prepare a fix for the engines and also for the documentation.

Thank you very much for highlighting this discrepancy.

@JosefBredereck
Copy link
Contributor

Have you updated the package @pattern-lab/engine-handlebars in the first project where you tried?
Would you mind reproducing it and hand me the error message you receive?

I tried it for myself with different options and none were giving me an error.

@StfBauer
Copy link
Contributor Author

StfBauer commented Feb 7, 2023

Where I started:

Screenshot 2023-02-07 at 09 51 17

I also had only extend in configuration:

  "engines": {
    "handlebars": {
      "extend": "helpers/*.js"
    }
  }

Which I then update to:

  "dependencies": {
    "@pattern-lab/cli": "^6.0.1",
    "@pattern-lab/core": "^6.0.1",
    "@pattern-lab/engine-handlebars": "^6.0.0",
    "@pattern-lab/uikit-bare": "^0.0.1",
    "@pattern-lab/uikit-workshop": "^6.0.1"
  }

After npm install and run pattern labs got the following message still with the extend in there:

image

I headed over to the documentation, pasted the prescribed change, and got the same message. That's how I provisioned a new project and figured out the misleading configuration there.

If you like reproducing it, you can use hTWOo.

  • Clone the repo
  • navigate to htwoo-core folder in there and try it for yourself

Thanks in advance.

@JosefBredereck
Copy link
Contributor

The only required parameter is the following and it is the source of the issue.
"package": "@pattern-lab/engine-handlebars",

The extend property will be used by the handlebars engine if you have extensions installed.

@StfBauer
Copy link
Contributor Author

StfBauer commented Feb 9, 2023

Am I correct? The only thing needed is:

  "engines": {
    "handlebars": {
      "package": "@pattern-lab/engine-handlebars",
      "extend": "helpers/hbs/*.js"
    }
  }

or could I remove even the "extend" and all the helpers will get recognised too?

@JosefBredereck
Copy link
Contributor

If you do not need the files located in https://github.com/n8design/htwoo/tree/main/htwoo-core/helpers loaded by handlebars, this is also not required and you can just use

  "engines": {
    "handlebars": {
      "package": "@pattern-lab/engine-handlebars",
    }
  }

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

Successfully merging a pull request may close this issue.

2 participants