esbuild-plugin-glsl
Advanced tools
Comparing version 1.0.3 to 1.0.4
/** | ||
* esbuild-plugin-glsl v1.0.3 build Sun Feb 21 2021 | ||
* esbuild-plugin-glsl v1.0.4 build Fri Aug 20 2021 | ||
* https://github.com/vanruesc/esbuild-plugin-glsl | ||
@@ -7,5 +7,5 @@ * Copyright 2021 Raoul van Rüschen | ||
*/ | ||
import{readFile as a}from"fs";import{promisify as u}from"util";function o(i){let n=/[ \t]*(?:(?:\/\*[\s\S]*?\*\/)|(?:\/\/.*\n))/g,l=/\s*({|}|=|\*|,|\+|\/|>|<|&|\||\[|\]|\(|\)|-|!|;)\s*/g,r=i.replace(/\r/g,"").replace(n,""),t=!1;return r=r.split(/\n+/).reduce((s,e)=>(e=e.trim().replace(/\s{2,}|\t/," "),e[0]==="#"?(t&&s.push(` | ||
`),s.push(e,` | ||
`),t=!1):(e=e.replace(/(else)$/m,"$1 "),s.push(e.replace(l,"$1")),t=!0),s),[]).join(""),r.replace(/\n{2,}/g,` | ||
`)}function p({minify:i=!1}={}){let n=u(a);return{name:"glsl",setup(l){l.onLoad({filter:/\.(?:frag|vert|glsl)$/},async r=>{let t=await n(r.path,"utf8");return{contents:i?o(t):t,loader:"text"}})}}}export{p as default,p as glsl}; | ||
import{readFile as u}from"fs";import{promisify as a}from"util";function l(n){let i=/[ \t]*(?:(?:\/\*[\s\S]*?\*\/)|(?:\/\/.*\n))/g,o=/\s*({|}|=|\*|,|\+|\/|>|<|&|\||\[|\]|\(|\)|-|!|;)\s*/g,t=n.replace(/\r/g,"").replace(i,""),s=!1;return t=t.split(/\n+/).reduce((e,r)=>(r=r.trim().replace(/\s{2,}|\t/," "),r[0]==="#"?(s&&e.push(` | ||
`),e.push(r,` | ||
`),s=!1):(r=r.replace(/(else)$/m,"$1 "),e.push(r.replace(o,"$1")),s=!0),e),[]).join(""),t.replace(/\n{2,}/g,` | ||
`)}function d({minify:n=!1}={}){let i=a(u);return{name:"glsl",setup(o){async function t(s){let e=await i(s.path,"utf8");return{contents:n?l(e):e,loader:"text"}}o.onLoad({filter:/\.(?:frag|vert|glsl)$/},t)}}}export{d as default,d as glsl}; |
{ | ||
"name": "esbuild-plugin-glsl", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A GLSL plugin for esbuild.", | ||
@@ -45,6 +45,6 @@ "homepage": "https://github.com/vanruesc/esbuild-plugin-glsl", | ||
"build:dts": "tsc -p tsconfig.d.json", | ||
"clean": "del-cli dist test/generated", | ||
"lint": "tsc --noemit && eslint src --fix", | ||
"prepublishOnly": "npm test", | ||
"pretest": "del-cli dist test/generated", | ||
"test": "run-s lint build ava" | ||
"test": "run-s lint clean build ava" | ||
}, | ||
@@ -58,9 +58,3 @@ "ava": { | ||
"eslintConfig": { | ||
"root": true, | ||
"extends": "aether/typescript", | ||
"parserOptions": { | ||
"project": [ | ||
"tsconfig.json" | ||
] | ||
} | ||
"extends": "aether/typescript" | ||
}, | ||
@@ -74,6 +68,7 @@ "engines": { | ||
"devDependencies": { | ||
"@types/node": "16.x.x", | ||
"@typescript-eslint/eslint-plugin": "4.x.x", | ||
"@typescript-eslint/parser": "4.x.x", | ||
"ava": "3.x.x", | ||
"del-cli": "3.x.x", | ||
"del-cli": "4.x.x", | ||
"esbuild": "0.x.x", | ||
@@ -80,0 +75,0 @@ "eslint": "7.x.x", |
@@ -30,4 +30,25 @@ # esbuild-plugin-glsl | ||
### TypeScript | ||
To make the TypeScript compiler know how to handle GLSL files, add a `glsl.d.ts` file to your project: | ||
```ts | ||
declare module "*.glsl" { | ||
const value: string; | ||
export default value; | ||
} | ||
declare module "*.frag" { | ||
const value: string; | ||
export default value; | ||
} | ||
declare module "*.vert" { | ||
const value: string; | ||
export default value; | ||
} | ||
``` | ||
## Contributing | ||
Use the issue tracker to propose and discuss changes. Maintain the existing coding style. Lint and test your code. |
Sorry, the diff of this file is not supported yet
6554
54
11