We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Resources from third party add-ons are not being included in compiled plone-legacy bundle
Seems JS resources registered in Plone 5 using old approach (`jsregistry.xml`) are not included in the final compilation: I installed an add-on and, even as I can see the JS resources listed in `default.js`, the source code is not present.

If I enable development mode, then I can see the source code included in `plone-legacy-compiled.js` and it's executed normally.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `Products/CMFPlone/resources/browser/combine.py`
Content:
```
1 from zExceptions import NotFound
2 from Acquisition import aq_base
3 from datetime import datetime
4 from plone.registry.interfaces import IRegistry
5 from plone.resource.file import FilesystemFile
6 from plone.resource.interfaces import IResourceDirectory
7 from Products.CMFPlone.interfaces import IBundleRegistry
8 from Products.CMFPlone.interfaces.resources import (
9     OVERRIDE_RESOURCE_DIRECTORY_NAME,
10 )
11 from StringIO import StringIO
12 from zope.component import getUtility
13 from zope.component import queryUtility
14 
15 PRODUCTION_RESOURCE_DIRECTORY = "production"
16 
17 
18 def get_production_resource_directory():
19     persistent_directory = queryUtility(IResourceDirectory, name="persistent")
20     if persistent_directory is None:
21         return ''
22     container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
23     try:
24         production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]
25     except NotFound:
26         return "%s/++unique++1" % PRODUCTION_RESOURCE_DIRECTORY
27     timestamp = production_folder.readFile('timestamp.txt')
28     return "%s/++unique++%s" % (
29         PRODUCTION_RESOURCE_DIRECTORY, timestamp)
30 
31 
32 def get_resource(context, path):
33     resource = context.unrestrictedTraverse(path)
34     if isinstance(resource, FilesystemFile):
35         (directory, sep, filename) = path.rpartition('/')
36         return context.unrestrictedTraverse(directory).readFile(filename)
37     else:
38         if hasattr(aq_base(resource), 'GET'):
39             # for FileResource
40             return resource.GET()
41         else:
42             # any BrowserView
43             return resource()
44 
45 
46 def write_js(context, folder, meta_bundle):
47     registry = getUtility(IRegistry)
48     resources = []
49 
50     # default resources
51     if meta_bundle == 'default' and registry.records.get(
52         'plone.resources/jquery.js'
53     ):
54         resources.append(get_resource(context,
55             registry.records['plone.resources/jquery.js'].value))
56         resources.append(get_resource(context,
57             registry.records['plone.resources.requirejs'].value))
58         resources.append(get_resource(context,
59             registry.records['plone.resources.configjs'].value))
60 
61     # bundles
62     bundles = registry.collectionOfInterface(
63         IBundleRegistry, prefix="plone.bundles", check=False)
64     for bundle in bundles.values():
65         if bundle.merge_with == meta_bundle:
66             resources.append(get_resource(context, bundle.jscompilation))
67 
68     fi = StringIO()
69     for script in resources:
70         fi.write(script + '\n')
71     folder.writeFile(meta_bundle + ".js", fi)
72 
73 
74 def write_css(context, folder, meta_bundle):
75     registry = getUtility(IRegistry)
76     resources = []
77 
78     bundles = registry.collectionOfInterface(
79         IBundleRegistry, prefix="plone.bundles", check=False)
80     for bundle in bundles.values():
81         if bundle.merge_with == meta_bundle:
82             resources.append(get_resource(context, bundle.csscompilation))
83 
84     fi = StringIO()
85     for script in resources:
86         fi.write(script + '\n')
87     folder.writeFile(meta_bundle + ".css", fi)
88 
89 
90 def combine_bundles(context):
91     persistent_directory = queryUtility(IResourceDirectory, name="persistent")
92     if persistent_directory is None:
93         return
94     if OVERRIDE_RESOURCE_DIRECTORY_NAME not in persistent_directory:
95         persistent_directory.makeDirectory(OVERRIDE_RESOURCE_DIRECTORY_NAME)
96     container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
97     if PRODUCTION_RESOURCE_DIRECTORY not in container:
98         container.makeDirectory(PRODUCTION_RESOURCE_DIRECTORY)
99     production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]
100 
101     # store timestamp
102     fi = StringIO()
103     fi.write(datetime.now().isoformat())
104     production_folder.writeFile("timestamp.txt", fi)
105 
106     # generate new combined bundles
107     write_js(context, production_folder, 'default')
108     write_js(context, production_folder, 'logged-in')
109     write_css(context, production_folder, 'default')
110     write_css(context, production_folder, 'logged-in')
111
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/Products/CMFPlone/resources/browser/combine.py b/Products/CMFPlone/resources/browser/combine.py
--- a/Products/CMFPlone/resources/browser/combine.py
+++ b/Products/CMFPlone/resources/browser/combine.py
@@ -30,6 +30,14 @@
 
 
 def get_resource(context, path):
+    if path.startswith('++plone++'):
+        # ++plone++ resources can be customized, we return their override
+        # value if any
+        overrides = get_override_directory(context)
+        filepath = path[9:]
+        if overrides.isFile(filepath):
+            return overrides.readFile(filepath)
+
     resource = context.unrestrictedTraverse(path)
     if isinstance(resource, FilesystemFile):
         (directory, sep, filename) = path.rpartition('/')
@@ -87,13 +95,17 @@
     folder.writeFile(meta_bundle + ".css", fi)
 
 
-def combine_bundles(context):
+def get_override_directory(context):
     persistent_directory = queryUtility(IResourceDirectory, name="persistent")
     if persistent_directory is None:
         return
     if OVERRIDE_RESOURCE_DIRECTORY_NAME not in persistent_directory:
         persistent_directory.makeDirectory(OVERRIDE_RESOURCE_DIRECTORY_NAME)
-    container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
+    return persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]
+
+
+def combine_bundles(context):
+    container = get_override_directory(context)
     if PRODUCTION_RESOURCE_DIRECTORY not in container:
         container.makeDirectory(PRODUCTION_RESOURCE_DIRECTORY)
     production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]

{"golden_diff": "diff --git a/Products/CMFPlone/resources/browser/combine.py b/Products/CMFPlone/resources/browser/combine.py\n--- a/Products/CMFPlone/resources/browser/combine.py\n+++ b/Products/CMFPlone/resources/browser/combine.py\n@@ -30,6 +30,14 @@\n \n \n def get_resource(context, path):\n+    if path.startswith('++plone++'):\n+        # ++plone++ resources can be customized, we return their override\n+        # value if any\n+        overrides = get_override_directory(context)\n+        filepath = path[9:]\n+        if overrides.isFile(filepath):\n+            return overrides.readFile(filepath)\n+\n     resource = context.unrestrictedTraverse(path)\n     if isinstance(resource, FilesystemFile):\n         (directory, sep, filename) = path.rpartition('/')\n@@ -87,13 +95,17 @@\n     folder.writeFile(meta_bundle + \".css\", fi)\n \n \n-def combine_bundles(context):\n+def get_override_directory(context):\n     persistent_directory = queryUtility(IResourceDirectory, name=\"persistent\")\n     if persistent_directory is None:\n         return\n     if OVERRIDE_RESOURCE_DIRECTORY_NAME not in persistent_directory:\n         persistent_directory.makeDirectory(OVERRIDE_RESOURCE_DIRECTORY_NAME)\n-    container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]\n+    return persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]\n+\n+\n+def combine_bundles(context):\n+    container = get_override_directory(context)\n     if PRODUCTION_RESOURCE_DIRECTORY not in container:\n         container.makeDirectory(PRODUCTION_RESOURCE_DIRECTORY)\n     production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]\n", "issue": "Resources from third party add-ons are not being included in compiled plone-legacy bundle\nSeems JS resources registered in Plone 5 using old approach (`jsregistry.xml`) are not included in the final compilation: I installed an add-on and, even as I can see the JS resources listed in `default.js`, the source code is not present.\n\nIf I enable development mode, then I can see the source code included in `plone-legacy-compiled.js` and it's executed normally.\n\n", "before_files": [{"content": "from zExceptions import NotFound\nfrom Acquisition import aq_base\nfrom datetime import datetime\nfrom plone.registry.interfaces import IRegistry\nfrom plone.resource.file import FilesystemFile\nfrom plone.resource.interfaces import IResourceDirectory\nfrom Products.CMFPlone.interfaces import IBundleRegistry\nfrom Products.CMFPlone.interfaces.resources import (\n    OVERRIDE_RESOURCE_DIRECTORY_NAME,\n)\nfrom StringIO import StringIO\nfrom zope.component import getUtility\nfrom zope.component import queryUtility\n\nPRODUCTION_RESOURCE_DIRECTORY = \"production\"\n\n\ndef get_production_resource_directory():\n    persistent_directory = queryUtility(IResourceDirectory, name=\"persistent\")\n    if persistent_directory is None:\n        return ''\n    container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]\n    try:\n        production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]\n    except NotFound:\n        return \"%s/++unique++1\" % PRODUCTION_RESOURCE_DIRECTORY\n    timestamp = production_folder.readFile('timestamp.txt')\n    return \"%s/++unique++%s\" % (\n        PRODUCTION_RESOURCE_DIRECTORY, timestamp)\n\n\ndef get_resource(context, path):\n    resource = context.unrestrictedTraverse(path)\n    if isinstance(resource, FilesystemFile):\n        (directory, sep, filename) = path.rpartition('/')\n        return context.unrestrictedTraverse(directory).readFile(filename)\n    else:\n        if hasattr(aq_base(resource), 'GET'):\n            # for FileResource\n            return resource.GET()\n        else:\n            # any BrowserView\n            return resource()\n\n\ndef write_js(context, folder, meta_bundle):\n    registry = getUtility(IRegistry)\n    resources = []\n\n    # default resources\n    if meta_bundle == 'default' and registry.records.get(\n        'plone.resources/jquery.js'\n    ):\n        resources.append(get_resource(context,\n            registry.records['plone.resources/jquery.js'].value))\n        resources.append(get_resource(context,\n            registry.records['plone.resources.requirejs'].value))\n        resources.append(get_resource(context,\n            registry.records['plone.resources.configjs'].value))\n\n    # bundles\n    bundles = registry.collectionOfInterface(\n        IBundleRegistry, prefix=\"plone.bundles\", check=False)\n    for bundle in bundles.values():\n        if bundle.merge_with == meta_bundle:\n            resources.append(get_resource(context, bundle.jscompilation))\n\n    fi = StringIO()\n    for script in resources:\n        fi.write(script + '\\n')\n    folder.writeFile(meta_bundle + \".js\", fi)\n\n\ndef write_css(context, folder, meta_bundle):\n    registry = getUtility(IRegistry)\n    resources = []\n\n    bundles = registry.collectionOfInterface(\n        IBundleRegistry, prefix=\"plone.bundles\", check=False)\n    for bundle in bundles.values():\n        if bundle.merge_with == meta_bundle:\n            resources.append(get_resource(context, bundle.csscompilation))\n\n    fi = StringIO()\n    for script in resources:\n        fi.write(script + '\\n')\n    folder.writeFile(meta_bundle + \".css\", fi)\n\n\ndef combine_bundles(context):\n    persistent_directory = queryUtility(IResourceDirectory, name=\"persistent\")\n    if persistent_directory is None:\n        return\n    if OVERRIDE_RESOURCE_DIRECTORY_NAME not in persistent_directory:\n        persistent_directory.makeDirectory(OVERRIDE_RESOURCE_DIRECTORY_NAME)\n    container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]\n    if PRODUCTION_RESOURCE_DIRECTORY not in container:\n        container.makeDirectory(PRODUCTION_RESOURCE_DIRECTORY)\n    production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]\n\n    # store timestamp\n    fi = StringIO()\n    fi.write(datetime.now().isoformat())\n    production_folder.writeFile(\"timestamp.txt\", fi)\n\n    # generate new combined bundles\n    write_js(context, production_folder, 'default')\n    write_js(context, production_folder, 'logged-in')\n    write_css(context, production_folder, 'default')\n    write_css(context, production_folder, 'logged-in')\n", "path": "Products/CMFPlone/resources/browser/combine.py"}], "after_files": [{"content": "from zExceptions import NotFound\nfrom Acquisition import aq_base\nfrom datetime import datetime\nfrom plone.registry.interfaces import IRegistry\nfrom plone.resource.file import FilesystemFile\nfrom plone.resource.interfaces import IResourceDirectory\nfrom Products.CMFPlone.interfaces import IBundleRegistry\nfrom Products.CMFPlone.interfaces.resources import (\n    OVERRIDE_RESOURCE_DIRECTORY_NAME,\n)\nfrom StringIO import StringIO\nfrom zope.component import getUtility\nfrom zope.component import queryUtility\n\nPRODUCTION_RESOURCE_DIRECTORY = \"production\"\n\n\ndef get_production_resource_directory():\n    persistent_directory = queryUtility(IResourceDirectory, name=\"persistent\")\n    if persistent_directory is None:\n        return ''\n    container = persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]\n    try:\n        production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]\n    except NotFound:\n        return \"%s/++unique++1\" % PRODUCTION_RESOURCE_DIRECTORY\n    timestamp = production_folder.readFile('timestamp.txt')\n    return \"%s/++unique++%s\" % (\n        PRODUCTION_RESOURCE_DIRECTORY, timestamp)\n\n\ndef get_resource(context, path):\n    if path.startswith('++plone++'):\n        # ++plone++ resources can be customized, we return their override\n        # value if any\n        overrides = get_override_directory(context)\n        filepath = path[9:]\n        if overrides.isFile(filepath):\n            return overrides.readFile(filepath)\n\n    resource = context.unrestrictedTraverse(path)\n    if isinstance(resource, FilesystemFile):\n        (directory, sep, filename) = path.rpartition('/')\n        return context.unrestrictedTraverse(directory).readFile(filename)\n    else:\n        if hasattr(aq_base(resource), 'GET'):\n            # for FileResource\n            return resource.GET()\n        else:\n            # any BrowserView\n            return resource()\n\n\ndef write_js(context, folder, meta_bundle):\n    registry = getUtility(IRegistry)\n    resources = []\n\n    # default resources\n    if meta_bundle == 'default' and registry.records.get(\n        'plone.resources/jquery.js'\n    ):\n        resources.append(get_resource(context,\n            registry.records['plone.resources/jquery.js'].value))\n        resources.append(get_resource(context,\n            registry.records['plone.resources.requirejs'].value))\n        resources.append(get_resource(context,\n            registry.records['plone.resources.configjs'].value))\n\n    # bundles\n    bundles = registry.collectionOfInterface(\n        IBundleRegistry, prefix=\"plone.bundles\", check=False)\n    for bundle in bundles.values():\n        if bundle.merge_with == meta_bundle:\n            resources.append(get_resource(context, bundle.jscompilation))\n\n    fi = StringIO()\n    for script in resources:\n        fi.write(script + '\\n')\n    folder.writeFile(meta_bundle + \".js\", fi)\n\n\ndef write_css(context, folder, meta_bundle):\n    registry = getUtility(IRegistry)\n    resources = []\n\n    bundles = registry.collectionOfInterface(\n        IBundleRegistry, prefix=\"plone.bundles\", check=False)\n    for bundle in bundles.values():\n        if bundle.merge_with == meta_bundle:\n            resources.append(get_resource(context, bundle.csscompilation))\n\n    fi = StringIO()\n    for script in resources:\n        fi.write(script + '\\n')\n    folder.writeFile(meta_bundle + \".css\", fi)\n\n\ndef get_override_directory(context):\n    persistent_directory = queryUtility(IResourceDirectory, name=\"persistent\")\n    if persistent_directory is None:\n        return\n    if OVERRIDE_RESOURCE_DIRECTORY_NAME not in persistent_directory:\n        persistent_directory.makeDirectory(OVERRIDE_RESOURCE_DIRECTORY_NAME)\n    return persistent_directory[OVERRIDE_RESOURCE_DIRECTORY_NAME]\n\n\ndef combine_bundles(context):\n    container = get_override_directory(context)\n    if PRODUCTION_RESOURCE_DIRECTORY not in container:\n        container.makeDirectory(PRODUCTION_RESOURCE_DIRECTORY)\n    production_folder = container[PRODUCTION_RESOURCE_DIRECTORY]\n\n    # store timestamp\n    fi = StringIO()\n    fi.write(datetime.now().isoformat())\n    production_folder.writeFile(\"timestamp.txt\", fi)\n\n    # generate new combined bundles\n    write_js(context, production_folder, 'default')\n    write_js(context, production_folder, 'logged-in')\n    write_css(context, production_folder, 'default')\n    write_css(context, production_folder, 'logged-in')\n", "path": "Products/CMFPlone/resources/browser/combine.py"}]}