Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
fix: Bundle#_unload
Browse files Browse the repository at this point in the history
- destroy all package watchers (except the project root)
- tell workers to drop the bundle
  • Loading branch information
aleclarson committed Jul 22, 2018
1 parent 86669f6 commit 2efa9a7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Bundle/index.coffee
@@ -1,4 +1,4 @@
{evalFile, extRegex, getCallSite, getModule, uhoh} = require '../utils'
{each, evalFile, extRegex, getCallSite, getModule, uhoh} = require '../utils'
{loadBundle, dropBundle} = require '../workers'
isObject = require 'is-object'
Emitter = require '@cush/events'
Expand Down Expand Up @@ -206,13 +206,13 @@ class Bundle extends Emitter
.then @_build.bind this

_unload: ->
@_invalidate() if @valid
dropBundle this

# Reset the main module.
@main.content = null
@main.deps = null

# Reset the asset cache.
# Clear the asset cache.
@assets = [, @main]
@_nextAssetId = 2

Expand All @@ -222,7 +222,13 @@ class Bundle extends Emitter
@root.assets[@main.name] = @main
@root.users = new Set

# Reset the package cache.
# Unwatch all packages (except the project root).
each @packages, (pack) =>
if pack isnt @root
pack.watcher?.destroy()
return

# Clear the package cache.
@packages = Object.create null
@packages[@root.data.name] =
new Map [[@root.data.version, @root]]
Expand Down

0 comments on commit 2efa9a7

Please sign in to comment.