Update to disk_build.git commit b8ff724
authorNick Downing <nick@ndcode.org>
Sun, 18 Nov 2018 11:26:29 +0000 (22:26 +1100)
committerNick Downing <nick@ndcode.org>
Sun, 18 Nov 2018 11:26:29 +0000 (22:26 +1100)
jst.js
package.json

diff --git a/jst.js b/jst.js
index 2669727..b71133e 100644 (file)
--- a/jst.js
+++ b/jst.js
@@ -23,6 +23,7 @@
 
 let BuildCache = require('@ndcode/build_cache')
 let acorn = require('./dist/acorn')
+let assert = require('assert')
 let astring = require('astring')
 let disk_build = require('@ndcode/disk_build')
 let fs = require('fs')
@@ -61,32 +62,30 @@ let jst = (pathname, root, args) => /*await*/ build_cache.get(
           arg_values.push(args[i])
         }
 
-    let full_built_pathname = require.resolve(
-      await disk_build(
-        pathname,
-        async built_pathname => {
-          let text = await fs_readFile(pathname, {encoding: 'utf-8'})
-          console.log('building', pathname)
-          return /*await*/ fs_writeFile(
-            built_pathname,
-            astring.generate(
-              transform.transform(
-                visitors,
-                acorn.parse(
-                  `module.exports = async (${arg_names.join(', ')}) => {${text}}`
-                )
-              ),
-              {} //indent: ''}
+    let render = await disk_build(
+      pathname,
+      async temp_pathname => {
+        let text = await fs_readFile(pathname, {encoding: 'utf-8'})
+        return /*await*/ fs_writeFile(
+          temp_pathname,
+          astring.generate(
+            transform.transform(
+              visitors,
+              acorn.parse(
+                `module.exports = async (${arg_names.join(', ')}) => {${text}}`
+              )
             ),
-            {encoding: 'utf-8'}
-          )
-        }
-      )
+            {} //indent: ''}
+          ),
+          {encoding: 'utf-8'}
+        )
+      },
+      true
     )
-    delete require.cache[full_built_pathname]
-    result.value = await (
-      require(full_built_pathname)
-    ).apply(null, arg_values)
+    assert(render.deps.length === 0)
+    let full_pathname = require.resolve(render.pathname)
+    delete require.cache[full_pathname]
+    result.value = await (require(full_pathname)).apply(null, arg_values)
   }
 )
 
index f6d927e..813820d 100644 (file)
@@ -27,6 +27,7 @@
     "@ndcode/build_cache": "^0.1.0",
     "@ndcode/clean-css": "^0.1.0",
     "@ndcode/disk_build": "^0.1.0",
+    "assert": "^1.4.1",
     "astring": "^1.3.1",
     "html-escape": "^2.0.0",
     "rollup": "^0.45.0",