express-tsx
Advanced tools
Comparing version 5.0.8 to 5.0.9
@@ -40,4 +40,9 @@ "use strict"; | ||
//set url | ||
app.get("/require.config.js" /* requirejsConfigJsPath */, (req, res) => res.type('js').header({ maxAge: 15 * 24 * 60 * 60 }).send(res.app.settings["requirejsConfigStr" /* requirejsConfigStr */])); | ||
app.get("/require.config.js" /* requirejsConfigJsPath */, (req, res) => { | ||
res | ||
.type('js') | ||
.header('Cache-Control', `max-age=${res.app.settings["compiler" /* compiler */].jsExpiredTime}`) | ||
.send(res.app.settings["requirejsConfigStr" /* requirejsConfigStr */]); | ||
}); | ||
}; | ||
//# sourceMappingURL=require.config.js.map |
{ | ||
"name": "express-tsx", | ||
"version": "5.0.8", | ||
"version": "5.0.9", | ||
"description": "express view engine to render tsx file", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -6,3 +6,4 @@ # 文档 | ||
```js | ||
var render = expressTsx(requirejsConfig,compiler=new Compiler()) | ||
/**@type {Express}*/ | ||
var app = expressTsx(viewsDir="/views",compiler=new Compiler()) | ||
@@ -9,0 +10,0 @@ ``` |
@@ -52,16 +52,19 @@ import { Express } from "express"; | ||
app.settings[key.requirejsId] = `store${cursor++}` | ||
Object.defineProperty(app.settings,key.requirejsConfig,{ | ||
get(){ return Requirejs.s.contexts[this.requirejsId].config }, | ||
set(config){ | ||
Requirejs.config({ context:this.requirejsId, ...config }) | ||
config = this[key.requirejsConfig] | ||
//remake config str | ||
let configStr = | ||
this[key.requirejsConfigStr] = | ||
`requirejs.config(${JSON.stringify({ ...config, context:'_', })})` | ||
//update hash path | ||
let hash = crypto.createHash('md5').update(configStr).digest('hex') | ||
this[key.requirejsConfigJsPathWithHash] = `${key.requirejsConfigJsPath}?${hash}` | ||
Object.defineProperty( | ||
app.settings, key.requirejsConfig, | ||
{ | ||
get(){ return Requirejs.s.contexts[this.requirejsId].config }, | ||
set(config){ | ||
Requirejs.config({ context:this.requirejsId, ...config }) | ||
config = this[key.requirejsConfig] | ||
//remake config str | ||
let configStr = | ||
this[key.requirejsConfigStr] = | ||
`requirejs.config(${JSON.stringify({ ...config, context:'_', })})` | ||
//update hash path | ||
let hash = crypto.createHash('md5').update(configStr).digest('hex') | ||
this[key.requirejsConfigJsPathWithHash] = `${key.requirejsConfigJsPath}?${hash}` | ||
} | ||
} | ||
}) | ||
) | ||
//set default config | ||
@@ -72,5 +75,10 @@ app.settings[key.requirejsConfig] = defaultRequirejsConfig | ||
key.requirejsConfigJsPath, | ||
(req,res)=> | ||
res.type('js').header({maxAge:15*24*60*60}).send(res.app.settings[key.requirejsConfigStr]) | ||
(req,res)=>{ | ||
res | ||
.type('js') | ||
//过期时间和 compiler 的过期时间保持一致 | ||
.header('Cache-Control',`max-age=${(res.app.settings[key.compiler] as Compile).jsExpiredTime}`) | ||
.send(res.app.settings[key.requirejsConfigStr]) | ||
} | ||
) | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45965
785
49