Skip to content

restore custom loader and import attribute test case for Lit renderer plugin #1463

@thescientist13

Description

@thescientist13

Task

As part of this PR, for some reason one specific test case failed, which was a combination of using Node custom loaders and Import Attributes, in that the resolved path to the nav.json file was returning an expected value from Rollup, that was a full path

{
  value: './packages/plugin-renderer-lit/test/cases/loaders-build.prerender.import-attributes/src/components/header/nav.json'
}

Error: ENOENT: no such file or directory, open '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/plugin-renderer-lit/test/cases/loaders-build.prerender.import-attributes/packages/plugin-renderer-lit/test/cases/loaders-build.prerender.import-attributes/src/components/header/nav.json'
    at Object.readFileSync (node:fs:441:20)
    at Object.ImportDeclaration (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/config/rollup.config.js:537:24)
    at c (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-walk/dist/walk.mjs:24:41)
    at Object.skipThrough (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-walk/dist/walk.mjs:180:37)
    at c (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-walk/dist/walk.mjs:23:22)
    at base.Program.base.BlockStatement.base.StaticBlock (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-walk/dist/walk.mjs:192:5)
    at c (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-walk/dist/walk.mjs:23:22)
    at Module.simple (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-walk/dist/walk.mjs:25:5)
    at Object.generateBundle (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/config/rollup.config.js:480:14)
    at file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/node-entry.js:20807:40 {
  errno: -2,
  code: 'PLUGIN_ERROR',
  syscall: 'open',
  path: '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/plugin-renderer-lit/test/cases/loaders-build.prerender.import-attributes/packages/plugin-renderer-lit/test/cases/loaders-build.prerender.import-attributes/src/components/header/nav.json',
  pluginCode: 'ENOENT',
  plugin: 'greenwood-sync-import-attributes',
  hook: 'generateBundle'
}

instead of the literal value as found in the code

{
  value: './src/components/header/nav.json'
}

I tested it in a couple repos outside of the monorepo and couldn't reproduce the issue though 🤷‍♂ 😕

Confirmed SSR was working and the JSON data was being SSR'd correctly

Image


Not sure if it's related to the monorepo setup? Maybe when working on #1315 and changing to a new package manager, this might get resolved? Or if there are other ways to test this outside the monorepo I'm not thinking of? Not sure why this particular change would affect Rollup in this way though...

Some things I tried

  • Removing as many params from the test:loaders script
  • Regenerated the monorepo yarn.lock file
  • Removing the data-gwd-opt="static" attribute from the <script> tag in the test case

So for the time being had to comment out the test 😬

Metadata

Metadata

Assignees

No one assigned

    Labels

    PluginsGreenwood PluginsSSRchoreunit testing, maintenance, etchelp wantedExtra attention is needed

    Type

    Projects

    Status

    🔖 Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions