Skip to content

Commit 5e14eb3

Browse files
committed
feat: Use new stats format on loader
1 parent a2f7fb8 commit 5e14eb3

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

webpack_loader/loader.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,22 @@ def get_assets(self):
3737
return self._assets[self.name]
3838
return self.load_assets()
3939

40-
def filter_chunks(self, chunks):
40+
def filter_chunks(self, chunks, files):
4141
for chunk in chunks:
42-
ignore = any(regex.match(chunk['name'])
42+
ignore = any(regex.match(chunk)
4343
for regex in self.config['ignores'])
4444
if not ignore:
45-
chunk['url'] = self.get_chunk_url(chunk)
46-
yield chunk
45+
url = self.get_chunk_url(chunk, files)
46+
yield { 'name': chunk, 'url': url }
4747

48-
def get_chunk_url(self, chunk):
49-
public_path = chunk.get('publicPath')
48+
def get_chunk_url(self, chunk, files):
49+
chunk_file = files[chunk]
50+
public_path = chunk_file.get('publicPath')
5051
if public_path:
5152
return public_path
5253

5354
relpath = '{0}{1}'.format(
54-
self.config['BUNDLE_DIR_NAME'], chunk['name']
55+
self.config['BUNDLE_DIR_NAME'], chunk
5556
)
5657
return staticfiles_storage.url(relpath)
5758

@@ -64,7 +65,7 @@ def get_bundle(self, bundle_name):
6465
timeout = self.config['TIMEOUT'] or 0
6566
timed_out = False
6667
start = time.time()
67-
while assets['status'] == 'compiling' and not timed_out:
68+
while (assets['status'] == 'compiling' or assets['status'] == 'compile') and not timed_out:
6869
time.sleep(self.config['POLL_INTERVAL'])
6970
if timeout and (time.time() - timeout > start):
7071
timed_out = True
@@ -80,7 +81,14 @@ def get_bundle(self, bundle_name):
8081
chunks = assets['chunks'].get(bundle_name, None)
8182
if chunks is None:
8283
raise WebpackBundleLookupError('Cannot resolve bundle {0}.'.format(bundle_name))
83-
return self.filter_chunks(chunks)
84+
85+
for chunk in chunks:
86+
asset = assets['assets'][chunk]
87+
if asset is None:
88+
raise WebpackBundleLookupError('Cannot resolve asset {0}.'.format(chunk))
89+
90+
files = assets['assets']
91+
return self.filter_chunks(chunks, files)
8492

8593
elif assets.get('status') == 'error':
8694
if 'file' not in assets:

0 commit comments

Comments
 (0)