Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/graph-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ function node (state, createEdge) {
b.transform(sheetify)
b.transform(glslify)

b.transform(brfs, { global: true })
b.transform(nanohtml, { global: true })

if (state.metadata.babelifyDeps) {
// Dependencies should be transformed, but their .babelrc should be ignored.
b.transform(tfilter(babelify, { include: /node_modules/ }), {
Expand Down Expand Up @@ -86,9 +89,6 @@ function node (state, createEdge) {
]
})

b.transform(brfs, { global: true })
b.transform(nanohtml, { global: true })

if (!fullPaths) b.plugin(cssExtract, { out: bundleStyles })

// split-require does not support `fullPaths: true` at the moment.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"keypress": "^0.2.1",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"nanohtml": "^1.2.4",
"nanohtml": "^1.7.0",
"nanologger": "^2.0.0",
"nanoraf": "^3.0.1",
"nanotiming": "^7.2.0",
Expand Down
31 changes: 31 additions & 0 deletions test/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,34 @@ tape('envify in watch mode', function (assert) {
compiler.graph.removeListener('change', next)
}
})

tape('apply nanohtml transform to scripts transpiled from typescript with esmoduleinterop', function (assert) {
assert.plan(3)

var file = `
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const choo_1 = __importDefault(require("choo"));
const html_1 = __importDefault(require("choo/html"));
const app = new choo_1.default();
app.route('/', function () {
return html_1.default \`<body>meow</body>\`;
});
module.exports = app.mount('body');
`

var tmpDir = tmp.dirSync({ dir: path.join(__dirname, '../tmp'), unsafeCleanup: true })
assert.on('end', tmpDir.removeCallback)
fs.writeFileSync(path.join(tmpDir.name, 'index.js'), file)

var compiler = bankai(tmpDir.name, { watch: false })
compiler.scripts('bundle.js', function (err, res) {
assert.ifError(err, 'no err bundling scripts')
var body = res.buffer.toString('utf8')
assert.equal(body.indexOf('html_1.default'), -1, 'choo/html is not used')
assert.equal(body.indexOf('<body>meow</body>'), -1, 'HTML string is tranformed')
})
})