django-webpack-loader icon indicating copy to clipboard operation
django-webpack-loader copied to clipboard

Need help with render_bundle after changing directory structure

Open gggrunt opened this issue 3 years ago • 3 comments

We have a legacy Django-webpack app using Django webpack loader. The app code moved into a /app directory and the render_bundle stopped working. The error message is

  File "/usr/local/lib/python3.9/site-packages/webpack_loader/templatetags/webpack_loader.py", line 22, in render_bundle
    tags = utils.get_as_tags(
  File "/usr/local/lib/python3.9/site-packages/webpack_loader/utils.py", line 71, in get_as_tags
    bundle = _get_bundle(loader, bundle_name, extension)
  File "/usr/local/lib/python3.9/site-packages/webpack_loader/utils.py", line 47, in _get_bundle
    bundle = loader.get_bundle(bundle_name)
  File "/usr/local/lib/python3.9/site-packages/webpack_loader/loader.py", line 116, in get_bundle
    filtered_chunks = self.filter_chunks(chunks)
  File "/usr/local/lib/python3.9/site-packages/webpack_loader/loader.py", line 58, in filter_chunks
    ignore = any(regex.match(chunk)
  File "/usr/local/lib/python3.9/site-packages/webpack_loader/loader.py", line 58, in <genexpr>
    ignore = any(regex.match(chunk)
TypeError: expected string or bytes-like object

Versions: django-webpack-loader: 1.6.0 webpack-bundle-tracker: 0.4.3

webpack-stats.json {"status":"done","publicPath":"http://localhost:8001/","chunks":{"app":[{"name":"app.js","publicPath":"http://localhost:8001/app.js","path":"/app/static/dist/app.js"}]}}

I hard-coded our STATICS_URL to try to match the documentation on django-webpack-loader STATIC_URL: /app/static/dist/ WEBPACK PATH(output.path): /app/static/dist

Code that triggers the error: {% render_bundle 'app' %} inside a index.html

WEBPACK_LOADER:

BASE_DIR = "/app"
STATIC_URL = "/app/static/dist/"
STATIC_ROOT = Path(BASE_DIR, "public")
STATICFILES_DIRS = [
    Path(BASE_DIR, "static"),
    Path(BASE_DIR, "static", "dist"),
]
WEBPACK_LOADER = {"DEFAULT": {"CACHE": not DEBUG}}

gggrunt avatar Jul 16 '22 19:07 gggrunt

@gggrunt could you please try upgrading your webpack-bundle-tracker to 1.6.0? Try to always match versions between webpack-bundle-tracker and django-webpack-loader.

fjsj avatar Aug 03 '22 13:08 fjsj

I'm also experiencing a similar issue, a TypeError when webpack-stats.json is parsed in django-webpack-loader. My webpack-stats is similarly built. Both webpack-bundle-tracker and django-webpack-loader are installed as version 1.6.0.

camvrgs avatar Aug 09 '22 17:08 camvrgs

@camvrgs sorry you're having issues, please share the whole error stacktrace.

fjsj avatar Aug 09 '22 18:08 fjsj

Hi @camvrgs, this looks similar to this issue https://github.com/django-webpack/django-webpack-loader/issues/324. We'll be updating any findings regarding this problem there.

rvlb avatar Sep 30 '22 20:09 rvlb

@camvrgs @gggrunt Please confirm you have the same version in django-webpack-loader and webpack-bundle-tracker like django-webpack-loader==1.6.0 and [email protected]. Both libs should always have the same version in projects.

This seems a duplicate of issue #324. Check this comment: https://github.com/django-webpack/django-webpack-loader/issues/324#issuecomment-1270691083

Closing for now.

fjsj avatar Oct 06 '22 21:10 fjsj