Comparing version 1.3.3 to 1.3.4
@@ -0,1 +1,11 @@ | ||
<a name="1.3.4"></a> | ||
## [1.3.4](https://github.com/kei-ito/esify/compare/v1.3.3...v1.3.4) (2019-09-04) | ||
### Bug Fixes | ||
* allow dynamic import ([1e3561b](https://github.com/kei-ito/esify/commit/1e3561b)) | ||
<a name="1.3.3"></a> | ||
@@ -2,0 +12,0 @@ ## [1.3.3](https://github.com/kei-ito/esify/compare/v1.3.2...v1.3.3) (2019-07-15) |
@@ -22,3 +22,5 @@ #!/usr/bin/env node | ||
loadParameters_1.loadParameters(exports.program) | ||
.then((parameters) => new Session_js_1.Session(parameters).start()) | ||
.then(async (parameters) => { | ||
await new Session_js_1.Session(parameters).start(); | ||
}) | ||
.catch((error) => { | ||
@@ -25,0 +27,0 @@ write_1.write(process.stderr, [error]); |
@@ -5,5 +5,8 @@ "use strict"; | ||
const acornWalk = require("acorn-walk"); | ||
const dynamicImport = require("acorn-dynamic-import"); | ||
const Parser = acorn.Parser.extend(dynamicImport.default || dynamicImport); | ||
acornWalk.base[dynamicImport.DynamicImportKey] = () => { }; | ||
exports.extractCSSFromScript = (script) => { | ||
const results = []; | ||
const ast = acorn.parse(script, { sourceType: 'module' }); | ||
const ast = Parser.parse(script, { sourceType: 'module' }); | ||
acornWalk.simple(ast, { | ||
@@ -10,0 +13,0 @@ ObjectExpression: (node) => { |
import { IParseResult } from './types'; | ||
import { IIdentifier } from '../util/createIdentifier'; | ||
export declare const minifyCSSInScript: (script: string, cssRanges: IParseResult[], identifier: IIdentifier) => string; | ||
export declare const minifyCSSInScript: (script: string, cssRanges: IParseResult[], identifier: IIdentifier) => Promise<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const encodeString_1 = require("../util/encodeString"); | ||
exports.minifyCSSInScript = (script, cssRanges, identifier) => { | ||
exports.minifyCSSInScript = async (script, cssRanges, identifier) => { | ||
let minified = script; | ||
@@ -14,4 +14,5 @@ for (let index = cssRanges.length; index--;) { | ||
} | ||
await Promise.resolve(null); | ||
return minified; | ||
}; | ||
//# sourceMappingURL=minifyCSSInScript.js.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
if (node.name === 'import') { | ||
const match = node.params.match(exports.REGEX_IMPORT); | ||
const match = exports.REGEX_IMPORT.exec(node.params); | ||
if (match) { | ||
@@ -14,0 +14,0 @@ count++; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const [importFrom, localName, ...others] = parameter.split(/\s+/); | ||
if (others.length === 0 && importFrom.match(/^(['"]).+\1/) && localName.match(/^[\w-]+$/)) { | ||
if (others.length === 0 && (/^(['"]).+\1/).exec(importFrom) && (/^[\w-]+$/).exec(localName)) { | ||
const from = importFrom.slice(1, -1); | ||
@@ -10,0 +10,0 @@ if (from.startsWith('.')) { |
@@ -25,5 +25,5 @@ /// <reference types="node" /> | ||
protected logError(...messages: Parameters<typeof write>[1]): void; | ||
protected stopWatcher(): void; | ||
protected stopWatcher(): Promise<void>; | ||
protected onError(error: Error): void; | ||
protected onFileEvent(eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', file: string, stats?: fs.Stats): void; | ||
protected onFileEvent(eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', file: string, stats?: fs.Stats): Promise<void>; | ||
protected onAdd(file: string, stats?: fs.Stats): Promise<void>; | ||
@@ -30,0 +30,0 @@ protected onChange(file: string, stats?: fs.Stats): Promise<void>; |
@@ -14,6 +14,2 @@ "use strict"; | ||
class Session { | ||
get helperScriptPath() { | ||
const srcDirectory = path.join(__dirname, '..', 'helper'); | ||
return path.join(srcDirectory, `index${this.configuration.ext}`); | ||
} | ||
constructor(parameters = {}) { | ||
@@ -24,2 +20,6 @@ this.configuration = getSessionConfiguration_1.getSessionConfiguration(parameters); | ||
} | ||
get helperScriptPath() { | ||
const srcDirectory = path.join(__dirname, '..', 'helper'); | ||
return path.join(srcDirectory, `index${this.configuration.ext}`); | ||
} | ||
async start() { | ||
@@ -32,4 +32,5 @@ await this.outputHelperScript(); | ||
} | ||
getHelperScript() { | ||
return fs_1.readFile(this.helperScriptPath, 'utf8'); | ||
async getHelperScript() { | ||
const scriptCode = await fs_1.readFile(this.helperScriptPath); | ||
return `${scriptCode}`; | ||
} | ||
@@ -54,3 +55,3 @@ async outputHelperScript() { | ||
async startWatcher() { | ||
this.stopWatcher(); | ||
await this.stopWatcher(); | ||
this.initialTask = []; | ||
@@ -62,3 +63,6 @@ this.log(`watching: ${this.configuration.path.join(', ')}`); | ||
if (this.configuration.extensions.has(path.extname(file))) { | ||
this.onFileEvent(eventName, file, stats); | ||
this.onFileEvent(eventName, file, stats) | ||
.catch((error) => { | ||
watcher.emit('error', error); | ||
}); | ||
} | ||
@@ -83,3 +87,3 @@ else { | ||
} | ||
stopWatcher() { | ||
async stopWatcher() { | ||
if (this.watcher) { | ||
@@ -89,2 +93,3 @@ this.watcher.close(); | ||
} | ||
await Promise.resolve(null); | ||
} | ||
@@ -94,3 +99,3 @@ onError(error) { | ||
} | ||
onFileEvent(eventName, file, stats) { | ||
async onFileEvent(eventName, file, stats) { | ||
this.log(`[${eventName}] ${file}`); | ||
@@ -103,9 +108,10 @@ switch (eventName) { | ||
} | ||
await promise; | ||
break; | ||
} | ||
case 'change': | ||
this.onChange(file, stats); | ||
await this.onChange(file, stats); | ||
break; | ||
case 'unlink': | ||
this.onUnlink(file); | ||
await this.onUnlink(file); | ||
break; | ||
@@ -115,4 +121,4 @@ default: | ||
} | ||
onAdd(file, stats) { | ||
return this.onChange(file, stats); | ||
async onAdd(file, stats) { | ||
await this.onChange(file, stats); | ||
} | ||
@@ -119,0 +125,0 @@ async onChange(file, stats) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.waitForInitialScanCompletion = (watcher) => new Promise((resolve, reject) => { | ||
watcher | ||
.once('error', reject) | ||
.once('ready', () => { | ||
watcher.removeListener('error', reject); | ||
resolve(); | ||
exports.waitForInitialScanCompletion = async (watcher) => { | ||
await new Promise((resolve, reject) => { | ||
watcher | ||
.once('error', reject) | ||
.once('ready', () => { | ||
watcher.removeListener('error', reject); | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
}; | ||
//# sourceMappingURL=waitForInitialScanCompletion.js.map |
@@ -6,3 +6,7 @@ "use strict"; | ||
const fs_1 = require("./fs"); | ||
exports.createTemporaryDirectory = (prefix = '') => fs_1.mkdtemp(path.join(os.tmpdir(), prefix || 'node-tmp-')); | ||
exports.createTemporaryDirectory = async (prefix = '') => { | ||
const pathPrefix = path.join(os.tmpdir(), prefix || 'node-tmp-'); | ||
const createdTemporaryDirectory = await fs_1.mkdtemp(pathPrefix); | ||
return createdTemporaryDirectory; | ||
}; | ||
//# sourceMappingURL=createTemporaryDirectory.js.map |
@@ -16,16 +16,18 @@ "use strict"; | ||
exports.copyFile = util.promisify(fs.copyFile); | ||
exports.writeFile = (dest, data, stdout = process.stdout) => new Promise((resolve, reject) => { | ||
createDirectoryFor_1.createDirectoryFor(dest); | ||
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data); | ||
fs.writeFile(dest, buffer, (error) => { | ||
if (error) { | ||
reject(error); | ||
} | ||
else { | ||
const isBig = 100000 < buffer.length; | ||
write_1.write(stdout, [`written: ${dest}${isBig ? ` ${buffer.length}bytes` : ''}`]); | ||
resolve(); | ||
} | ||
exports.writeFile = async (dest, data, stdout = process.stdout) => { | ||
await new Promise((resolve, reject) => { | ||
createDirectoryFor_1.createDirectoryFor(dest); | ||
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data); | ||
fs.writeFile(dest, buffer, (error) => { | ||
if (error) { | ||
reject(error); | ||
} | ||
else { | ||
const isBig = 100000 < buffer.length; | ||
write_1.write(stdout, [`written: ${dest}${isBig ? ` ${buffer.length}bytes` : ''}`]); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}); | ||
}; | ||
exports.deleteFile = async (filePath, stdout = process.stdout) => { | ||
@@ -41,3 +43,5 @@ try { | ||
const files = (await exports.readdir(filePath)).map((name) => path.join(filePath, name)); | ||
await Promise.all(files.map((file) => exports.deleteFile(file, stdout))); | ||
await Promise.all(files.map(async (file) => { | ||
await exports.deleteFile(file, stdout); | ||
})); | ||
await exports.rmdir(filePath); | ||
@@ -44,0 +48,0 @@ } |
{ | ||
"name": "esifycss", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Generates .js or .ts exports class names and custom properties", | ||
@@ -49,7 +49,8 @@ "author": { | ||
"dependencies": { | ||
"@nlib/nbnf": "^3.12.0", | ||
"acorn": "^6.2.0", | ||
"acorn-walk": "^6.2.0", | ||
"@nlib/nbnf": "^3.13.3", | ||
"acorn": "^7.0.0", | ||
"acorn-dynamic-import": "^4.0.0", | ||
"acorn-walk": "^7.0.0", | ||
"chokidar": "^3.0.2", | ||
"commander": "^2.20.0", | ||
"commander": "^3.0.1", | ||
"postcss": "^7.0.17", | ||
@@ -62,3 +63,4 @@ "postcss-selector-parser": "^6.0.2", | ||
"@commitlint/config-conventional": "^8.0.0", | ||
"@nlib/lint": "^3.12.0", | ||
"@nlib/lint": "^3.13.3", | ||
"@types/acorn-dynamic-import": "file:@types/acorn-dynamic-import", | ||
"@types/acorn-walk": "file:@types/acorn-walk", | ||
@@ -68,20 +70,20 @@ "@types/anymatch": "^1.3.1", | ||
"@types/micromatch": "3.1.0", | ||
"@types/node": "^12.6.2", | ||
"@types/selenium-webdriver": "^4.0.1", | ||
"@typescript-eslint/eslint-plugin": "^1.12.0", | ||
"@typescript-eslint/parser": "^1.12.0", | ||
"ava": "^2.2.0", | ||
"browserstack-local": "^1.4.0", | ||
"conventional-changelog-cli": "^2.0.21", | ||
"@types/node": "^12.7.4", | ||
"@types/selenium-webdriver": "^4.0.2", | ||
"@typescript-eslint/eslint-plugin": "^2.1.0", | ||
"@typescript-eslint/parser": "^2.1.0", | ||
"ava": "^2.3.0", | ||
"browserstack-local": "^1.4.2", | ||
"conventional-changelog-cli": "^2.0.23", | ||
"cpy-cli": "^2.0.0", | ||
"eslint": "^6.0.1", | ||
"husky": "^3.0.0", | ||
"lint-staged": "^9.2.0", | ||
"eslint": "^6.3.0", | ||
"husky": "^3.0.5", | ||
"lint-staged": "^9.2.5", | ||
"npm-run-all": "^4.1.5", | ||
"postcss-nested": "4.1.2", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.17.0", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^1.20.3", | ||
"selenium-webdriver": "^4.0.0-alpha.4", | ||
"ts-node": "^8.3.0", | ||
"typescript": "^3.5.3" | ||
"typescript": "^3.6.2" | ||
}, | ||
@@ -109,2 +111,10 @@ "ava": { | ||
"files": [ | ||
"scripts/*.ts" | ||
], | ||
"parserOptions": { | ||
"project": "scripts/tsconfig.json" | ||
} | ||
}, | ||
{ | ||
"files": [ | ||
"src/helper/**/*", | ||
@@ -124,2 +134,5 @@ "test/*/src/*" | ||
"no-bitwise": "off" | ||
}, | ||
"parserOptions": { | ||
"project": "./tsconfig.helper.json" | ||
} | ||
@@ -126,0 +139,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
151097
179
1754
9
26
+ Addedacorn-dynamic-import@^4.0.0
+ Addedacorn@7.4.1(transitive)
+ Addedacorn-dynamic-import@4.0.0(transitive)
+ Addedacorn-walk@7.2.0(transitive)
+ Addedcommander@3.0.2(transitive)
- Removedacorn-walk@6.2.0(transitive)
- Removedcommander@2.20.3(transitive)
Updated@nlib/nbnf@^3.13.3
Updatedacorn@^7.0.0
Updatedacorn-walk@^7.0.0
Updatedcommander@^3.0.1