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

@after-work.js/transform

Package Overview
Dependencies
Maintainers
4
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@after-work.js/transform - npm Package Compare versions

Comparing version 6.0.13 to 7.0.0-alpha.0

8

package.json
{
"name": "@after-work.js/transform",
"version": "6.0.13",
"version": "7.0.0-alpha.0",
"publishConfig": {

@@ -23,4 +23,4 @@ "access": "public"

"dependencies": {
"@after-work.js/utils": "6.0.13",
"find-cache-dir": "3.3.0",
"@after-work.js/utils": "7.0.0-alpha.0",
"find-cache-dir": "3.3.1",
"import-cwd": "3.0.0"

@@ -31,3 +31,3 @@ },

],
"gitHead": "1ae4d0bd13053bc2b420d410de9c512ee5c6cb2a"
"gitHead": "689884010c7bd56512bb31a79bb3bfdc599df554"
}
/* eslint class-methods-use-this: 0, no-restricted-syntax: 0, guard-for-in: 0, no-await-in-loop: 0, max-len: 0 */
const path = require('path');
const findCacheDir = require('find-cache-dir');
const fs = require('fs');
const zlib = require('zlib');
const crypto = require('crypto');
const path = require("path");
const findCacheDir = require("find-cache-dir");
const fs = require("fs");
const zlib = require("zlib");
const crypto = require("crypto");

@@ -12,3 +12,3 @@ class FileCache {

this.cacheDir = findCacheDir({
name: '@after-work.js/transform',
name: "@after-work.js/transform",
create: true,

@@ -20,6 +20,3 @@ });

getCacheFilename(filename) {
const hash = crypto
.createHash('md5')
.update(filename)
.digest('hex');
const hash = crypto.createHash("md5").update(filename).digest("hex");
return path.join(this.cacheDir, `${hash}.json.gz`);

@@ -33,6 +30,3 @@ }

});
return crypto
.createHash('md5')
.update(data)
.digest('hex');
return crypto.createHash("md5").update(data).digest("hex");
}

@@ -47,5 +41,3 @@

setSync(filename, transformItem, options) {
const {
virtualMock, babelOptions, instrument, transform,
} = options;
const { virtualMock, babelOptions, instrument, transform } = options;
transformItem.hash = this.getCacheHash(filename, {

@@ -113,3 +105,3 @@ ...babelOptions,

const gz = zlib.gzipSync(str);
fs.writeFileSync(this.getCacheFilename(filename), gz, 'utf8');
fs.writeFileSync(this.getCacheFilename(filename), gz, "utf8");
} catch (err) {

@@ -116,0 +108,0 @@ console.error(err);

/* eslint global-require: 0, import/no-dynamic-require: 0, object-curly-newline: 0, class-methods-use-this: 0, max-len: 0 */
const fs = require('fs');
const fs = require("fs");
const {

@@ -9,7 +9,7 @@ isSourceMap,

isTestFile,
} = require('@after-work.js/utils');
const FileCache = require('./file-cache');
} = require("@after-work.js/utils");
const FileCache = require("./file-cache");
const fileCache = new FileCache();
const debug = createDebug('transform');
const debug = createDebug("transform");

@@ -22,7 +22,8 @@ function getBabelOpts(filename, argv) {

const virtualMock = !!argv.virtualMock;
const addCoverage = virtualMock === false && isTestFile(filename, argv) === false;
const addCoverage =
virtualMock === false && isTestFile(filename, argv) === false;
const usePlugins = addCoverage
? [...plugins, [babelPluginIstanbul, argv.nyc]]
: plugins;
const sourceMaps = 'both';
const sourceMaps = "both";
const retainLines = true;

@@ -39,3 +40,3 @@ const opts = {

};
debug('getBabelOpts', opts);
debug("getBabelOpts", opts);
return opts;

@@ -61,3 +62,3 @@ }

if (!compilerOptions.module) {
compilerOptions.module = __isNodeRunner ? 'commonjs' : 'esnext';
compilerOptions.module = __isNodeRunner ? "commonjs" : "esnext";
}

@@ -68,3 +69,3 @@ const transpileOpts = { fileName, compilerOptions };

let tsBabelOpts = {
sourceMaps: 'both',
sourceMaps: "both",
};

@@ -77,13 +78,13 @@

tsBabelOpts = Object.assign(babelOptions, tsBabelOpts);
debug(':transformTypescript', tsContent, tsBabelOpts);
debug(":transformTypescript", tsContent, tsBabelOpts);
return { tsContent, tsBabelOpts };
}
function transformFile(filename, argv, content = null) {
debug(':transformFile');
debug(":transformFile");
if (!content && isSourceMap(filename)) {
const cachedTransform = fileCache.getSync(
filename.split('.map').join(''),
argv,
filename.split(".map").join(""),
argv
);
debug(':transformFile cached source map', cachedTransform);
debug(":transformFile cached source map", cachedTransform);
return cachedTransform.map;

@@ -98,11 +99,11 @@ }

if (cachedTransform) {
debug(':transformFile cached transform', cachedTransform);
debug(":transformFile cached transform", cachedTransform);
return cachedTransform.code;
}
content = fs.readFileSync(filename, 'utf8');
content = fs.readFileSync(filename, "utf8");
}
const cachedTransform = fileCache.getSync(filename, argv);
if (cachedTransform) {
debug(':transformFile cached transform', cachedTransform);
debug(":transformFile cached transform", cachedTransform);
return cachedTransform.code;

@@ -116,3 +117,3 @@ }

content,
argv,
argv
);

@@ -125,5 +126,5 @@ content = tsContent;

const transform = babel.transform(content, babelOpts);
debug(':transformFile transform', transform);
debug(":transformFile transform", transform);
if (!transform) {
debug(':transformFile transform null');
debug(":transformFile transform null");
return content;

@@ -135,4 +136,5 @@ }

const getTransform = filename => fileCache.getSync(filename, { ignoreCacheInvalidation: true });
const deleteTransform = filename => fileCache.transform.delete(filename);
const getTransform = (filename) =>
fileCache.getSync(filename, { ignoreCacheInvalidation: true });
const deleteTransform = (filename) => fileCache.transform.delete(filename);
const safeSaveCache = () => fileCache.saveSync();

@@ -139,0 +141,0 @@

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