Comparing version 0.16.1 to 0.16.2
@@ -0,1 +1,7 @@ | ||
## 0.16.2 | ||
- Fixed alias resolving | ||
- Target Node 10.3.0 | ||
- New property `meta` in Plugin Context | ||
- Fixed issue with cache when dependencies change | ||
## 0.16.1 | ||
@@ -2,0 +8,0 @@ - Support for PostCSS 8 |
@@ -25,2 +25,15 @@ "use strict"; | ||
const noop = () => { }; | ||
const getETag = (filePath) => { | ||
let eTag = '' + Math.floor(fs_1.default.statSync(filePath).mtimeMs); | ||
const deps = instance.cache.filesData.files[filePath].dependencies; | ||
if (deps) { | ||
Object.keys(deps).sort().forEach((dependency) => { | ||
try { | ||
eTag += Math.floor(fs_1.default.statSync(dependency).mtimeMs); | ||
} | ||
catch (e) { /* Do nothing */ } | ||
}); | ||
} | ||
return eTag; | ||
}; | ||
return async (ctx) => { | ||
@@ -61,7 +74,7 @@ if (!initialized) { | ||
cache.saveData(); | ||
if (config.cacheOnMemory) | ||
memoizedFiles.set(filePath, transformedCode); | ||
ctx.set('ETag', getETag(filePath)); | ||
} | ||
if (config.cacheOnMemory) | ||
memoizedFiles.set(filePath, transformedCode); | ||
watcher.setDependencies(filePath, dependencies); | ||
ctx.set('ETag', mtime + ''); | ||
}; | ||
@@ -88,10 +101,10 @@ if (cache.filesData.files[filePath]) { | ||
cache.saveData(); | ||
if (config.cacheOnMemory) | ||
memoizedFiles.set(filePath, transformedCode); | ||
ctx.set('ETag', getETag(filePath)); | ||
} | ||
if (config.cacheOnMemory) | ||
memoizedFiles.set(filePath, transformedCode); | ||
watcher.setDependencies(filePath, dependencies); | ||
ctx.set('ETag', mtime + ''); | ||
} | ||
else { | ||
if (ctx.get('If-None-Match') === mtime + '') { | ||
if (ctx.get('If-None-Match') === getETag(filePath)) { | ||
ctx.status = 304; | ||
@@ -98,0 +111,0 @@ } |
@@ -34,5 +34,5 @@ /// <reference types="babel__traverse" /> | ||
export interface PluginContext { | ||
config: ReboostConfig; | ||
addDependency: (dependency: string) => void; | ||
chalk: typeof chalk; | ||
config: ReboostConfig; | ||
getCompatibleSourceMap: (map: RawSourceMap) => RawSourceMap; | ||
@@ -42,2 +42,3 @@ getSourceMapComment: (map: any) => string; | ||
mergeSourceMaps: typeof mergeSourceMaps; | ||
meta: Record<string, any>; | ||
resolve: PublicResolveFn; | ||
@@ -155,3 +156,3 @@ } | ||
} | ||
declare const createInstance: (initialConfig: ReboostConfig) => Promise<{ | ||
declare const createInstance: (initialConfig: ReboostConfig) => Promise<false | { | ||
exports: ReboostService; | ||
@@ -186,3 +187,4 @@ proxyAddress: string; | ||
}; | ||
Init(): boolean; | ||
/** Returns false if no entry found. If it returns false, close the app without further execution */ | ||
Init(): any; | ||
isLogEnabled(type: keyof Exclude<ReboostConfig['log'], boolean>): boolean; | ||
@@ -192,4 +194,4 @@ log(type: keyof Exclude<ReboostConfig['log'], boolean>, ...toLog: any[]): void; | ||
}>; | ||
export interface ReboostInstance extends PromiseType<ReturnType<typeof createInstance>> { | ||
export interface ReboostInstance extends Exclude<PromiseType<ReturnType<typeof createInstance>>, false> { | ||
} | ||
export declare const start: (config?: ReboostConfig) => Promise<ReboostService>; |
@@ -95,2 +95,3 @@ "use strict"; | ||
cache: {}, | ||
/** Returns false if no entry found. If it returns false, close the app without further execution */ | ||
Init() { | ||
@@ -101,3 +102,3 @@ // Config initialization | ||
console.log(chalk_1.default.red('No entry found. Please add some entries first.')); | ||
return true; | ||
return false; | ||
} | ||
@@ -117,3 +118,5 @@ if (!path_1.default.isAbsolute(it.config.rootDir)) | ||
it.config.resolve.modules = [].concat(it.config.resolve.modules); | ||
it.config.resolve.modules.slice().forEach((modDirName) => { | ||
// Add absolute path for relative modules dir path, so that resolve can work | ||
// for any plugins to load peerDependencies | ||
it.config.resolve.modules.forEach((modDirName) => { | ||
if (path_1.default.isAbsolute(modDirName)) | ||
@@ -123,2 +126,26 @@ return; | ||
}); | ||
const resolveAlias = it.config.resolve.alias; | ||
if (resolveAlias) { | ||
if (Array.isArray(resolveAlias)) { | ||
resolveAlias.forEach((aliasData) => { | ||
if (Array.isArray(aliasData.alias)) { | ||
aliasData.alias = aliasData.alias.map((aPath) => (aPath.startsWith('.') ? path_1.default.join(it.config.rootDir, aPath) : aPath)); | ||
} | ||
else if (aliasData.alias && aliasData.alias.startsWith('.')) { | ||
aliasData.alias = path_1.default.join(it.config.rootDir, aliasData.alias); | ||
} | ||
}); | ||
} | ||
else { | ||
Object.keys(resolveAlias).forEach((key) => { | ||
const aliasPath = resolveAlias[key]; | ||
if (Array.isArray(aliasPath)) { | ||
resolveAlias[key] = aliasPath.map((aPath) => (aPath.startsWith('.') ? path_1.default.join(it.config.rootDir, aPath) : aPath)); | ||
} | ||
else if (aliasPath && aliasPath.startsWith('.')) { | ||
resolveAlias[key] = path_1.default.join(it.config.rootDir, aliasPath); | ||
} | ||
}); | ||
} | ||
} | ||
utils_1.deepFreeze(it.config); | ||
@@ -177,5 +204,4 @@ // Plugins initialization | ||
// Initialize all properties | ||
const shouldClose = it.Init(); | ||
if (shouldClose) | ||
return; | ||
if (it.Init() === false) | ||
return false; | ||
if (it.config.dumpCache) | ||
@@ -231,2 +257,6 @@ utils_1.rmDir(it.config.cacheDir); | ||
utils_1.ensureDir(path_1.default.dirname(outputPath)); | ||
if (!fs_1.default.existsSync(path_1.default.join(it.config.rootDir, input))) { | ||
it.log('info', chalk_1.default.red(`The input file does not exist: ${JSON.stringify(input)}`)); | ||
continue; | ||
} | ||
let fileContent = `import '${fullAddress}/setup';\n`; | ||
@@ -233,0 +263,0 @@ fileContent += 'import'; |
@@ -38,7 +38,8 @@ "use strict"; | ||
const getPluginContext = (instance, filePath, mergedDependencies) => ({ | ||
chalk: chalk_1.default, | ||
config: instance.config, | ||
meta: {}, | ||
addDependency(dependency) { | ||
mergedDependencies.push(path_1.default.normalize(dependency)); | ||
}, | ||
chalk: chalk_1.default, | ||
getCompatibleSourceMap: (map) => getCompatibleSourceMap(instance, map), | ||
@@ -45,0 +46,0 @@ getSourceMapComment(map) { |
{ | ||
"name": "reboost", | ||
"version": "0.16.1", | ||
"version": "0.16.2", | ||
"description": "A super fast dev server for rapid web development", | ||
"main": "./dist/node/index.js", | ||
"types": "./dist/node/index.d.ts", | ||
"engines": { | ||
"node": ">= 10.3.0" | ||
}, | ||
"scripts": { | ||
@@ -83,3 +86,3 @@ "prepublishOnly": "npm run clean && npm run build", | ||
}, | ||
"gitHead": "7e1ba07eebde0b6aaa369ab00a13284ee8af1500" | ||
"gitHead": "5833d8072df2972d2d31014043e5279567bb3428" | ||
} |
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
164213
3409