mischnic / parcel-plugin-sw-cache

📦👷 Parcel plugin for caching using a service worker
https://npm.im/parcel-plugin-sw-cache
MIT License
47 stars 6 forks source link

Cannot read property 'package' of null #12

Closed jessehattabaugh closed 5 years ago

jessehattabaugh commented 5 years ago

I get an error when I bundle:

Cannot read property 'package' of null
    at Bundler.bundler.on.bundle (C:\Users\me\node_modules\parcel-plugin-sw-cache\index.js:30:54)

coming from this line

I tried adding the cache property to my package.json. but it didn't help.

I'm on Windows 10, the error occurs in PowerShell and WSL Ubuntu Bash

jessehattabaugh commented 5 years ago

I tried uncommenting the line above, and commenting out the line with the error and it works fine now.

mischnic commented 5 years ago

Which version of parcel are you using?

jessehattabaugh commented 5 years ago

Parcel 1.9.7 Node 10.9.0

mischnic commented 5 years ago

The only message I get with the included example and Parcel 1.9.7 is: asset.package is deprecated. Please use await asset.getPackage() instead.`.

jessehattabaugh commented 5 years ago

I don't get that message

On Wed, Sep 5, 2018 at 11:54 PM Niklas Mischkulnig notifications@github.com wrote:

The only message I get with the included example and Parcel 1.9.7 is: asset.package is deprecated. Please use await asset.getPackage() instead.`.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mischnic/parcel-plugin-sw-cache/issues/12#issuecomment-418985280, or mute the thread https://github.com/notifications/unsubscribe-auth/AABGR-mGV5_WOXXH-ZYB6-XP3_rSgXQIks5uYMaIgaJpZM4WbtXI .

jessehattabaugh commented 5 years ago

Any idea when you'll have time to fix this?

mischnic commented 5 years ago

Any idea when you'll have time to fix this?

I can't reproduce it (yet). Which version of parcel-plugin-sw-cache do you have installed? (Latest is v0.2.5).

Could you please insert this: console.log(bundle.entryAsset); before the line where the error happens and post the output?

Do you get this error with the included example? (Clone parcel-plugin-sw-cache, run npm i or yarn inside the example folder and run the start or build script.

jessehattabaugh commented 5 years ago

I am using "parcel-plugin-sw-cache": "^0.2.5".

console.log(bundle.entryAsset); outputs null

console.dir(bundle); outputs this;

Bundle {
  type: undefined,
  name: undefined,
  parentBundle: undefined,
  entryAsset: null,
  assets: Set {},
  childBundles:
   Set {
     Bundle {
       type: 'html',
       name:
        'C:\\Users\\Jesse Hattabaugh\\jessehattabaugh-com\\dist\\index.html',
       parentBundle: [Circular],
       entryAsset: [HTMLAsset],
       assets: [Set],
       childBundles: [Set],
       siblingBundles: Set {},
       siblingBundlesMap: Map {},
       offsets: Map {},
       totalSize: 7858,
       bundleTime: 1784,
       isolated: undefined },
     Bundle {
       type: 'html',
       name:
        'C:\\Users\\Jesse Hattabaugh\\jessehattabaugh-com\\dist\\share.html',
       parentBundle: [Circular],
       entryAsset: [HTMLAsset],
       assets: [Set],
       childBundles: Set {},
       siblingBundles: Set {},
       siblingBundlesMap: Map {},
       offsets: Map {},
       totalSize: 2499,
       bundleTime: 1821,
       isolated: undefined } },
  siblingBundles: Set {},
  siblingBundlesMap: Map {},
  offsets: Map {},
  totalSize: 0,
  bundleTime: 0,
  isolated: undefined }

When I run example I get the error that you mentioned: Parcel 1.9.7 is: asset.package is deprecated. Please use await asset.getPackage() instead.

I notice that the example is using "parcel-bundler": "^1.9.0", "parcel-plugin-sw-cache": "^0.2.0"

mischnic commented 5 years ago

I get your error now as well, it's because you have multiple entry points (e.g. parcel src/index.html src/page.html).

jessehattabaugh commented 5 years ago

Yes, my build command is parcel build src/*.html and there are two .html files in /src. Is that not supported by this plugin?

mischnic commented 5 years ago

Is that not supported by this plugin?

Please test with version 0.2.6.

jessehattabaugh commented 5 years ago

Woo hoo! Working fine! Much appreciated!