Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/compiler

Package Overview
Dependencies
Maintainers
1
Versions
300
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/compiler - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

2

package.json

@@ -24,3 +24,3 @@ {

"scripts": {},
"version": "0.0.8"
"version": "0.0.9"
}

@@ -64,3 +64,3 @@ import * as fs from 'fs';

static invalidWorkingSetFile(name: string) {
for (let re of this.invalidWorkingSetFiles) {
for (const re of this.invalidWorkingSetFiles) {
if (re.test(name)) {

@@ -75,3 +75,3 @@ return true;

if (!AppEnv.prod || this.optionalFiles.test(p)) { // If attempting to load an optional require
let extra = this.optionalFiles.test(p) ? 'optional ' : '';
const extra = this.optionalFiles.test(p) ? 'optional ' : '';
console.error(`Unable to import ${extra}require, ${p}, stubbing out`, e);

@@ -89,3 +89,3 @@ return true;

static resolveOptions(name = this.configFile) {
let out = ts.parseJsonSourceFileConfigFileContent(
const out = ts.parseJsonSourceFileConfigFileContent(
ts.readJsonConfigFile(`${this.cwd}/${this.configFile}`, x => ts.sys.readFile(x)), {

@@ -114,5 +114,5 @@ useCaseSensitiveFileNames: true,

for (let trns of bulkRequire(this.transformerSet)) {
for (let key of Object.keys(trns)) {
let item = trns[key];
for (const trns of bulkRequire(this.transformerSet)) {
for (const key of Object.keys(trns)) {
const item = trns[key];
if (!transformers[item.phase]) {

@@ -126,3 +126,3 @@ transformers[item.phase] = [];

}
for (let key of Object.keys(transformers)) {
for (const key of Object.keys(transformers)) {
transformers[key] = (transformers[key] as any[]).sort((a, b) => a.priority - b.priority).map(x => x.transformer);

@@ -139,3 +139,3 @@ }

} catch (e) {
let p = Module._resolveFilename(request, parent);
const p = Module._resolveFilename(request, parent);
this.handleLoadError(p, e);

@@ -149,6 +149,6 @@ mod = {};

if (AppEnv.watch) {
let p = Module._resolveFilename(request, parent);
const p = Module._resolveFilename(request, parent);
if (p.includes(process.cwd()) && !p.includes(this.libraryPath)) {
if (!this.modules.has(p)) {
let handler = new RetargettingHandler(mod);
const handler = new RetargettingHandler(mod);
out = new Proxy({}, handler);

@@ -175,3 +175,3 @@ this.modules.set(p, { module: out, handler });

let isNew = !this.contents.has(jsf);
const isNew = !this.contents.has(jsf);

@@ -195,3 +195,3 @@ if (isNew) {

try {
let ret = (m as any)._compile(content, jsf);
const ret = (m as any)._compile(content, jsf);
if (isNew) {

@@ -220,3 +220,3 @@ this.events.emit('required-after', tsf);

}
for (let fileName of files) {
for (const fileName of files) {
this.unload(fileName);

@@ -242,7 +242,7 @@ // Do not automatically reload

// let output = this.langaugeService.getEmitOutput(fileName);
let content = ts.sys.readFile(fileName)!;
const content = ts.sys.readFile(fileName)!;
if (AppEnv.watch && this.hashes.has(fileName)) {
// Let's see if they are really different
let hash = farmhash.hash32(content);
const hash = farmhash.hash32(content);
if (hash === this.hashes.get(fileName)) {

@@ -254,3 +254,3 @@ console.debug('File contents unchanged');

let res = this.transpile(content, fileName);
const res = this.transpile(content, fileName);
let output = res.outputText;

@@ -260,3 +260,3 @@ if (fileName.match(/\/test\//)) {

}
let outFileName = toJsName(fileName);
const outFileName = toJsName(fileName);

@@ -283,3 +283,3 @@ if (this.logErrors(fileName, res.diagnostics)) {

static watchFiles(fileNames: string[]) {
let watcher = chokidar.watch(this.appWorkingSet, {
const watcher = chokidar.watch(this.appWorkingSet, {
ignored: this.invalidWorkingSetFile,

@@ -305,3 +305,3 @@ persistent: true,

fileName = `${process.cwd()}/${fileName}`;
let changed = this.files.has(fileName);
const changed = this.files.has(fileName);
if (changed) {

@@ -337,6 +337,6 @@ this.snaphost.delete(fileName);

for (let diagnostic of diagnostics) {
let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
for (const diagnostic of diagnostics) {
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
if (diagnostic.file) {
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start as number);
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start as number);
console.error(` Error ${diagnostic.file.fileName}(${line + 1}, ${character + 1}): ${message}`);

@@ -363,3 +363,3 @@ } else {

if (!this.snaphost.has(fileName)) {
let snap = fs.existsSync(fileName) ? ts.ScriptSnapshot.fromString(ts.sys.readFile(fileName)!) : undefined
const snap = fs.existsSync(fileName) ? ts.ScriptSnapshot.fromString(ts.sys.readFile(fileName)!) : undefined
this.snaphost.set(fileName, snap);

@@ -374,3 +374,3 @@ }

this.prepareSourceMaps();
let out = this.resolveOptions();
const out = this.resolveOptions();
this.options = out.options;

@@ -390,3 +390,3 @@

}
let start = Date.now();
const start = Date.now();

@@ -420,3 +420,3 @@

// Prime for type checker
for (let fileName of this.rootFiles) {
for (const fileName of this.rootFiles) {
this.files.set(fileName, { version: 0 });

@@ -423,0 +423,0 @@ this.emitFile(fileName);

@@ -49,3 +49,3 @@ export class RetargettingHandler<T extends any> implements ProxyHandler<T> {

ownKeys(target: T): PropertyKey[] {
let keys = ([] as PropertyKey[])
const keys = ([] as PropertyKey[])
.concat(Object.getOwnPropertyNames(this.target))

@@ -52,0 +52,0 @@ .concat(Object.getOwnPropertySymbols(this.target));

@@ -45,4 +45,4 @@ import { Compiler } from './compiler';

static findAnyDecorator(node: ts.Node, patterns: { [key: string]: Set<string> }, state: State): ts.Decorator | undefined {
for (let dec of (node.decorators || []) as any as DecList) {
let ident = this.getDecoratorIdent(dec);
for (const dec of (node.decorators || []) as any as DecList) {
const ident = this.getDecoratorIdent(dec);
if (!ts.isIdentifier(ident)) {

@@ -52,4 +52,4 @@ continue;

if (ident && ident.escapedText in patterns) {
let { path } = state.imports.get(ident.escapedText! as string)!;
let packages = patterns[ident.escapedText as string];
const { path } = state.imports.get(ident.escapedText! as string)!;
const packages = patterns[ident.escapedText as string];
if (path.includes('@travetto') || (!path.includes('node_modules') && AppInfo.PACKAGE === '@travetto')) {

@@ -71,5 +71,5 @@ let pkg = '';

static addImport(file: ts.SourceFile, imports: Import[]) {
let importStmts = imports
const importStmts = imports
.map(({ path, ident }) => {
let imptStmt = ts.createImportDeclaration(
const imptStmt = ts.createImportDeclaration(
undefined, undefined,

@@ -111,4 +111,4 @@ ts.createImportClause(undefined, ts.createNamespaceImport(ident)),

} else {
let pairs: ts.PropertyAssignment[] = [];
for (let k of Object.keys(val)) {
const pairs: ts.PropertyAssignment[] = [];
for (const k of Object.keys(val)) {
pairs.push(

@@ -125,4 +125,4 @@ ts.createPropertyAssignment(k, this.fromLiteral(val[k]))

lit = lit || this.fromLiteral({});
let props = lit.properties;
let extra = this.fromLiteral(addTo).properties;
const props = lit.properties;
const extra = this.fromLiteral(addTo).properties;
return ts.updateObjectLiteral(lit, [...props, ...extra]);

@@ -162,3 +162,3 @@ }

(file: ts.SourceFile) => {
let state = init(file, context) as T;
const state = init(file, context) as T;
state.path = require.resolve(file.fileName);

@@ -168,3 +168,3 @@ state.newImports = [];

for (let stmt of file.statements) {
for (const stmt of file.statements) {
if (ts.isImportDeclaration(stmt) && ts.isStringLiteral(stmt.moduleSpecifier)) {

@@ -178,7 +178,7 @@ let path = '';

if (stmt.importClause.namedBindings) {
let bindings = stmt.importClause.namedBindings;
const bindings = stmt.importClause.namedBindings;
if (ts.isNamespaceImport(bindings)) {
state.imports.set(bindings.name.text, { path, ident: bindings.name })
} else if (ts.isNamedImports(bindings)) {
for (let n of bindings.elements) {
for (const n of bindings.elements) {
state.imports.set(n.name.text, { path, ident: n.name })

@@ -192,3 +192,3 @@ }

let ret = visitor(context, file, state);
const ret = visitor(context, file, state);

@@ -205,3 +205,3 @@ if (state.newImports.length) {

let nodeName = (typeNode as any).typeName!.getText();
const nodeName = (typeNode as any).typeName!.getText();
if (nodeName.match(/^[A-Z]{1,3}$/)) {

@@ -212,5 +212,5 @@ throw new Error('Type information not found');

if (nodeName.indexOf('.') > 0) {
let [importName, ident] = nodeName.split('.');
const [importName, ident] = nodeName.split('.');
if (state.imports.has(importName)) {
let importIdent = ts.createUniqueName(`import_${importName}`);
const importIdent = ts.createUniqueName(`import_${importName}`);

@@ -226,6 +226,6 @@ state.newImports.push({

} else {
let ident = nodeName;
const ident = nodeName;
// External
if (state.imports.has(nodeName)) {
let importName = ts.createUniqueName(`import_${nodeName}`);
const importName = ts.createUniqueName(`import_${nodeName}`);

@@ -244,5 +244,5 @@ state.newImports.push({

static buildImportAliasMap(pathToType: { [key: string]: string } = {}) {
let out: { [key: string]: Set<string> } = {};
const out: { [key: string]: Set<string> } = {};
for (let [k, v] of Object.entries(pathToType)) {
for (const [k, v] of Object.entries(pathToType)) {
if (!(v in out)) {

@@ -249,0 +249,0 @@ out[v] = new Set();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc