Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caches.delete() not working #333

Open
thomkok18 opened this issue Jan 2, 2020 · 1 comment
Open

caches.delete() not working #333

thomkok18 opened this issue Jan 2, 2020 · 1 comment

Comments

@thomkok18
Copy link

I am building a service worker. The code works, but for some reason yuicompressor is not minifing the code, because of caches.delete();

My code

self.addEventListener('activate', function (e) {
    // console.log("service worker has been activated");

    e.waitUntil(caches.keys().then(function (cacheNames) {
        return Promise.all(cacheNames.filter(function (key) {
            return key !== staticCache;
        }).map(function (key) {
             return caches.delete(key); // error occurs here
        }));
    }));
});

Yuicompressor error

"D:\Program Files\JetBrains\IntelliJ IDEA 2019.2.4\jbr/bin/java" -jar D:\xampp\htdocs\portfolio-thom\node_modules\yuicompressor\build\yuicompressor-2.4.8.jar sw.js -v -o sw.min.js

[INFO] Using charset UTF-8
[ERROR] in sw.js
  36:34:missing name after . operator
[ERROR] in sw.js
  1:0:Compilation produced 1 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 1 syntax errors.
	at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:172)
	at org.mozilla.javascript.Parser.parse(Parser.java:396)
	at org.mozilla.javascript.Parser.parse(Parser.java:340)
	at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:315)
	at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:536)
	at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:147)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)

Process finished with exit code 2
@vl-80
Copy link

vl-80 commented May 28, 2022

Try using a different notation for accessing the delete method:

return caches["delete"](key);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants