Skip to content
Closed
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
3 changes: 3 additions & 0 deletions fixtures/glsl/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const fs = require('fs')
const glsl = require('glslify')
glsl(fs.readFileSync(__dirname + '/shader.glsl', 'utf8'))
2 changes: 2 additions & 0 deletions fixtures/glsl/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const glsl = require('glslify')
glsl(["#define GLSLIFY 1\nvoid main () { gl_Position = vec4(1); }\n"])
10 changes: 10 additions & 0 deletions fixtures/glsl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "fixture",
"version": "1.0.0",
"browserify": {
"transform": [
"brfs",
"glslify"
]
}
}
1 change: 1 addition & 0 deletions fixtures/glsl/shader.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void main () { gl_Position = vec4(1); }
6 changes: 6 additions & 0 deletions fixtures/glsl/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
loaders: [
test: /\.(glsl|vert|v|frag|f)$/,
loader: 'ify-loader'
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
},
"devDependencies": {
"brfs": "^1.4.2",
"glslify": "^6.1.0",
"npm-which": "^2.0.0",
"regl": "^1.3.0",
"standard": "^5.4.1",
"tap-spec": "^4.1.1",
"tape": "^4.4.0",
"through2": "^2.0.0",
"webpack": "^2.2.1"
"webpack": "^3.4.0"
},
"scripts": {
"test": "node test.js | tspec",
Expand Down
39 changes: 38 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ test('ify-loader', function (t) {
log: function (src) {
const expected = fs.readFileSync(pkg, { encoding: 'utf8' })
t.equal(src, expected, 'processed brfs from package.json')
}
},
error: console.error
}
})
})
Expand Down Expand Up @@ -87,3 +88,39 @@ test('error handling', function (t) {
t.equal(code, 2, 'exit code was 2')
})
})

test('glsl-transform', function (t) {
const wpack = which.sync('webpack', { cwd: __dirname })
const input = path.join(__dirname, 'fixtures', 'glsl', 'index.js')
const output = path.join(__dirname, 'fixtures', 'glsl', 'bundle.js')
const pkg = path.join(__dirname, 'fixtures', 'glsl', 'output.js')

t.plan(1)

try {
fs.unlinkSync(output)
} catch (e) {}

spawn(wpack, [
input,
output,
'--module-bind', 'js=' + __dirname
], {
stdio: ['pipe', 'pipe', 2]
}).once('exit', function () {
const result = fs.readFileSync(output, { encoding: 'utf8' })

fs.unlinkSync(output)

vm.runInNewContext(result, {
console: {
log: function (src) {
const expected = fs.readFileSync(pkg, { encoding: 'utf8' })
t.equal(src, expected, 'processed brfs from package.json')
},
error: console.error
}
})
})
})