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

Strings within filters not updating in .eleventy.js on serve/reload (v1.0.0-beta.8). #2147

Closed
dwkns opened this issue Dec 22, 2021 · 1 comment
Labels
bug: --serve restart Changes to projects shouldn’t need to restart dev server bug feature: 🛠 configuration Related to Eleventy’s Configuration file

Comments

@dwkns
Copy link

dwkns commented Dec 22, 2021

Describe the bug
In 0.12.1 editing a string within Filter in .eleventy.js while using npx @11ty/eleventy --serve triggers a reload and outputs to console and return statement correctly. In v1.0.0-beta.8 it does not.

Initial build (or restart server) corrects the issue.

To Reproduce
Create:
package.json

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@11ty/eleventy": "^0.12.1"
  },
  "scripts": {
    "start": "NODE_ENV=development npx @11ty/eleventy --serve"
  }
}

index.njk

---
title: The title
---
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>{{title}}</title>
</head>
<body>
  <p>Hello {{title | someFilter}}</p>
</body>
</html>

.eleventy.js

module.exports = (eleventyConfig) => {
  console.log('------ Outside filter'); 

  eleventyConfig.addFilter('someFilter', (someValue) => {
    var today = new Date();
    console.log(`------ The date: ${today} `);
    console.log(`------ Inside Filter`); 

    return `${someValue} at ${today}`;
  })

  return {
    dir: {
      output: '_site',
    },
  };
}
  1. Install with yarn and run with yarn start
  2. Edit text of console.log('------ Outside filter'); in .eleventy.js save and output is as expected.
  3. Edit text of console.log('------ Inside Filter'); in .eleventy.js save and output is as expected.
  4. Quit server
  5. Update package.json to "@11ty/eleventy": "v1.0.0-beta.8"
  6. Install with yarn and run with yarn start
  7. Edit text of console.log('------ Outside filter'); in .eleventy.js save and output is as expected.
  8. Edit text of console.log('------ Inside Filter'); in .eleventy.js save and console output DOES NOT UPDATE.
  9. Editing text in the return statement also DOES NOT update the template (unless you restart the server).

This only happens using --serve not on initial build. And only happens in v1.0.0-beta.8 not in 0.12.1. Note variables within Filters still seem to update (as with Date function above).

Expected behavior
Would expect v1.0.0-beta.8 behaviour to match 0.12.1

Environment:

  • OS and Version: MacOS 12.1 (M1)
  • Eleventy Version 0.12.1 / v1.0.0-beta.8

Additional context
Add any other context about the problem here.

@zachleat zachleat added this to the Eleventy v1.0.1 milestone Jan 9, 2022
@zachleat zachleat added bug and removed needs-triage labels Apr 14, 2022
@zachleat
Copy link
Member

Shipping with 2.0.0-canary.5

@zachleat zachleat added feature: 🛠 configuration Related to Eleventy’s Configuration file bug: --serve restart Changes to projects shouldn’t need to restart dev server labels Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: --serve restart Changes to projects shouldn’t need to restart dev server bug feature: 🛠 configuration Related to Eleventy’s Configuration file
Projects
None yet
Development

No branches or pull requests

2 participants