Skip to content

Entry asset wrongly detected in manifest.json #5

@lubomirblazekcz

Description

@lubomirblazekcz

Version: 1.0.4

Bug Description

https://github.com/nette/assets/blob/master/src/Assets/ViteMapper.php#L72

This detection is not reliable, if the entry in manifest doesn't include imports or css it can still be an entry file. Why detecting dependencies in the first place? Isn't isEntry: true enough?

This is a valid entry file:

{
  "src/scripts/main.js": {
    "file": "assets/main-CUcetFYf.js",
    "name": "main",
    "src": "src/scripts/main.js",
    "isEntry": true,
    "dynamicImports": [
      "node_modules/tsparticles/browser/index.js",
      "node_modules/@tsparticles/engine/browser/index.js"
    ]
  },
}

This currently doesn't work. The current setup works only if you import css through js, which should be required. Often it's better to include css separately in the template for better dx.

Steps To Reproduce

https://github.com/nette/web-project/blob/master/config/common.neon#L30 - uncomment vite

  • run npm run build

This will be in the html, which is wrong:

<script src="http://localhost:8000/assets/main-C9MBXU7D.js" crossorigin=""></script>

Every javascript entry file in Vite should have type="module"

Expected Behavior

<script src="http://localhost:8000/assets/main-C9MBXU7D.js" crossorigin="" type="module"></script>

Possible Solution

You should check both ($entry || $dependencies)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions