1

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 DJANGO STATICS_URL: /app/static/dist/ WEBPACK PATH(output.path): /app/static/dist

WEBPACK_LOADER Code:

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}}

Code that triggers the error:

 {% render_bundle 'app' %} inside a index.html
gggrunt
  • 31
  • 3

1 Answers1

0

I have same issue from legacy code...

TypeError at / expected string or bytes-like object

this is ./manage.py runserver output...

tags = utils.get_as_tags( File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/utils.py", line 71, in get_as_tags bundle = _get_bundle(loader, bundle_name, extension) File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/utils.py", line 47, in _get_bundle bundle = loader.get_bundle(bundle_name) File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/loader.py", line 116, in get_bundle filtered_chunks = self.filter_chunks(chunks) File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/loader.py", line 58, in filter_chunks ignore = any(regex.match(chunk) File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/loader.py", line 58, in ignore = any(regex.match(chunk) TypeError: expected string or bytes-like object

user3647449
  • 398
  • 2
  • 2