return err
        }
 
-       opts.sourcefile = ctx.SourcePath
-       opts.resolveDir = t.c.rs.WorkingDir
+       opts.sourceDir = filepath.FromSlash(path.Dir(ctx.SourcePath))
+       opts.resolveDir = t.c.rs.WorkingDir // where node_modules gets resolved
        opts.contents = string(src)
        opts.mediaType = ctx.InMediaType
 
 
        mediaType  media.Type
        outDir     string
        contents   string
-       sourcefile string
+       sourceDir  string
        resolveDir string
        tsConfig   string
 }
                        }
                        relDir = filepath.Dir(rel)
                } else {
-                       relDir = filepath.Dir(opts.sourcefile)
+                       relDir = opts.sourceDir
                }
 
                // Imports not starting with a "." is assumed to live relative to /assets.