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

@swc/cli

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swc/cli - npm Package Compare versions

Comparing version 0.1.55 to 0.1.56

2

lib/spack/index.js

@@ -67,1 +67,3 @@ "use strict";

})();
//# sourceMappingURL=index.js.map

89

lib/spack/options.js

@@ -10,2 +10,42 @@ "use strict";

var path = _interopRequireWildcard(require("path"));
async function parseSpackArgs(args) {
//
const cmd = _commander.default.parse(args);
const opts = cmd.opts();
const cliOptions = {
// watch: !!opts.watch,
debug: !!opts.debug
};
var _config;
const configOpts = await (0, _spack).compileBundleOptions((_config = opts.config) !== null && _config !== void 0 ? _config : path.resolve('spack.config.js'));
if (opts.entry) {
configOpts.entry = opts.entry;
}
if (opts.mode) {
configOpts.mode = opts.mode;
}
if (opts.target) {
configOpts.target = opts.target;
}
if (!configOpts.output) {
configOpts.output = {};
}
if (!configOpts.output.path) {
var _outputPath;
configOpts.output.path = (_outputPath = opts.outputPath) !== null && _outputPath !== void 0 ? _outputPath : '[name].js';
}
if (!configOpts.output.name) {
var _output;
configOpts.output.name = (_output = opts.output) !== null && _output !== void 0 ? _output : '[name].js';
}
// if (!configOpts.output.name) {
// configOpts.output.path = opts.outputPath;
// }
return {
cliOptions,
spackOptions: {
...configOpts
}
};
}
function _interopRequireDefault(obj) {

@@ -20,9 +60,7 @@ return obj && obj.__esModule ? obj : {

} else {
var newObj = {
};
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
};
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {

@@ -170,43 +208,2 @@ Object.defineProperty(newObj, key, desc);

@swc/core: ${_core.version}`);
async function parseSpackArgs(args) {
//
const cmd = _commander.default.parse(args);
const opts = cmd.opts();
const cliOptions = {
// watch: !!opts.watch,
debug: !!opts.debug
};
var _config;
const configOpts = await (0, _spack).compileBundleOptions((_config = opts.config) !== null && _config !== void 0 ? _config : path.resolve('spack.config.js'));
if (opts.entry) {
configOpts.entry = opts.entry;
}
if (opts.mode) {
configOpts.mode = opts.mode;
}
if (opts.target) {
configOpts.target = opts.target;
}
if (!configOpts.output) {
configOpts.output = {
};
}
if (!configOpts.output.path) {
var _outputPath;
configOpts.output.path = (_outputPath = opts.outputPath) !== null && _outputPath !== void 0 ? _outputPath : '[name].js';
}
if (!configOpts.output.name) {
var _output;
configOpts.output.name = (_output = opts.output) !== null && _output !== void 0 ? _output : '[name].js';
}
// if (!configOpts.output.name) {
// configOpts.output.path = opts.outputPath;
// }
return {
cliOptions,
spackOptions: {
...configOpts
}
};
}
function collect(value, previousValue) {

@@ -218,1 +215,3 @@ // If the user passed the option with no value, like "babel file.js --presets", do nothing.

}
//# sourceMappingURL=options.js.map

@@ -8,12 +8,10 @@ "use strict";

const fsMock = jest.createMockFromModule('fs');
let mockStats = {
};
function setMockStats(stats) {
Object.entries(stats).forEach(([path, stats1])=>{
mockStats[path] = stats1;
let mockStats = {};
function setMockStats(stats1) {
Object.entries(stats1).forEach(([path, stats])=>{
mockStats[path] = stats;
});
}
function resetMockStats() {
mockStats = {
};
mockStats = {};
}

@@ -33,1 +31,3 @@ function stat(path, cb) {

exports.default = _default;
//# sourceMappingURL=fs.js.map

@@ -7,4 +7,3 @@ "use strict";

it("compile with sync transform", async ()=>{
const options = {
};
const options = {};
await (0, _compile).compile('test.ts', options, true, undefined);

@@ -14,4 +13,3 @@ expect(_core.transformFileSync).toHaveBeenCalledWith('test.ts', options);

it("compile with async transform", async ()=>{
const options = {
};
const options = {};
await (0, _compile).compile('test.ts', options, false, undefined);

@@ -21,1 +19,3 @@ expect(_core.transformFile).toHaveBeenCalledWith('test.ts', options);

});
//# sourceMappingURL=compile.test.js.map

@@ -13,9 +13,7 @@ "use strict";

} else {
var newObj = {
};
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
};
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {

@@ -65,4 +63,3 @@ Object.defineProperty(newObj, key, desc);

"parser": undefined,
"transform": {
}
"transform": {}
},

@@ -96,6 +93,4 @@ "sourceFileName": undefined,

//@ts-expect-error
mockExit = jest.spyOn(process, 'exit').mockImplementation(()=>{
});
mockConsoleError = jest.spyOn(console, 'error').mockImplementation(()=>{
});
mockExit = jest.spyOn(process, 'exit').mockImplementation(()=>{});
mockConsoleError = jest.spyOn(console, 'error').mockImplementation(()=>{});
});

@@ -301,1 +296,3 @@ beforeEach(()=>{

});
//# sourceMappingURL=options.test.js.map

@@ -159,1 +159,3 @@ "use strict";

});
//# sourceMappingURL=sources.test.js.map

@@ -26,6 +26,6 @@ "use strict";

if (options.sourceFileName) {
sourceMap['sources'][0] = options.sourceFileName;
sourceMap["sources"][0] = options.sourceFileName;
}
if (options.sourceRoot) {
sourceMap['sourceRoot'] = options.sourceRoot;
sourceMap["sourceRoot"] = options.sourceRoot;
}

@@ -59,3 +59,3 @@ output.map = JSON.stringify(sourceMap);

mode
})
}),
]);

@@ -80,1 +80,3 @@ }

}
//# sourceMappingURL=compile.js.map

@@ -8,8 +8,9 @@ "use strict";

exports.CompileStatus = CompileStatus;
(function(CompileStatus1) {
CompileStatus1[CompileStatus1["Copied"] = 0] = "Copied";
CompileStatus1[CompileStatus1["Compiled"] = 1] = "Compiled";
CompileStatus1[CompileStatus1["Omitted"] = 2] = "Omitted";
CompileStatus1[CompileStatus1["Failed"] = 3] = "Failed";
})(CompileStatus || (exports.CompileStatus = CompileStatus = {
}));
(function(CompileStatus) {
CompileStatus[CompileStatus["Copied"] = 0] = "Copied";
CompileStatus[CompileStatus["Compiled"] = 1] = "Compiled";
CompileStatus[CompileStatus["Omitted"] = 2] = "Omitted";
CompileStatus[CompileStatus["Failed"] = 3] = "Failed";
})(CompileStatus || (exports.CompileStatus = CompileStatus = {}));
//# sourceMappingURL=constants.js.map

@@ -13,2 +13,10 @@ "use strict";

var _sources = require("./sources");
async function dir({ cliOptions , swcOptions }) {
const { watch } = cliOptions;
await beforeStartCompilation(cliOptions);
await initialCompilation(cliOptions, swcOptions);
if (watch) {
await watchCompilation(cliOptions, swcOptions);
}
}
function _interopRequireDefault(obj) {

@@ -61,5 +69,5 @@ return obj && obj.__esModule ? obj : {

const dest = getDest(filename, outDir);
const dir = (0, _path).dirname(dest);
const dir1 = (0, _path).dirname(dest);
console.log(filename);
await mkdir(dir, recursive);
await mkdir(dir1, recursive);
await copyFile(filename, dest);

@@ -132,8 +140,8 @@ return _constants.CompileStatus.Copied;

let failed = 0;
let compiled = 0;
let copied = 0;
for (let [_, status] of results){
switch(status){
let compiled1 = 0;
let copied1 = 0;
for (let [_, status1] of results){
switch(status1){
case _constants.CompileStatus.Compiled:
compiled += 1;
compiled1 += 1;
break;

@@ -144,16 +152,16 @@ case _constants.CompileStatus.Failed:

case _constants.CompileStatus.Copied:
copied += 1;
copied1 += 1;
break;
}
}
if (!quiet && compiled + copied) {
if (!quiet && compiled1 + copied1) {
let message = "";
if (compiled) {
message += `Successfully compiled: ${compiled} ${compiled > 1 ? "files" : "file"}`;
if (compiled1) {
message += `Successfully compiled: ${compiled1} ${compiled1 > 1 ? "files" : "file"}`;
}
if (compiled && copied) {
if (compiled1 && copied1) {
message += ", ";
}
if (copied) {
message += `copied ${copied} ${copied > 1 ? "files" : "file"}`;
if (copied1) {
message += `copied ${copied1} ${copied1 > 1 ? "files" : "file"}`;
}

@@ -166,3 +174,6 @@ message += ` with swc (%dms)`;

if (!watch) {
throw new Error("Failed to compile");
const files = Array.from(results.entries()).filter(([, status])=>status === _constants.CompileStatus.Failed
).map(([filename, _])=>filename
).join("\n");
throw new Error(`Failed to compile:\n${files}`);
}

@@ -224,9 +235,3 @@ }

}
async function dir({ cliOptions , swcOptions }) {
const { watch } = cliOptions;
await beforeStartCompilation(cliOptions);
await initialCompilation(cliOptions, swcOptions);
if (watch) {
await watchCompilation(cliOptions, swcOptions);
}
}
//# sourceMappingURL=dir.js.map

@@ -20,9 +20,7 @@ "use strict";

} else {
var newObj = {
};
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
};
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {

@@ -112,13 +110,13 @@ Object.defineProperty(newObj, key, desc);

let results = await getProgram();
for (const filename of results.keys()){
for (const filename1 of results.keys()){
try {
const result = await handle(filename);
const result = await handle(filename1);
if (result) {
results.set(filename, result);
results.set(filename1, result);
} else {
results.delete(filename);
results.delete(filename1);
}
} catch (err) {
console.error(err.message);
results.set(filename, err);
results.set(filename1, err);
}

@@ -139,4 +137,4 @@ }

});
watcher.on("add", async (filename1)=>{
if ((0, _sources).isCompilableExtension(filename1, cliOptions.extensions)) {
watcher.on("add", async (filename)=>{
if ((0, _sources).isCompilableExtension(filename, cliOptions.extensions)) {
// ensure consistent insertion order when files are added

@@ -146,4 +144,4 @@ results = await getProgram(results);

});
watcher.on("unlink", (filename1)=>{
results.delete(filename1);
watcher.on("unlink", (filename)=>{
results.delete(filename);
});

@@ -154,13 +152,13 @@ for (const type of [

]){
watcher.on(type, (filename1)=>{
if (!(0, _sources).isCompilableExtension(filename1, cliOptions.extensions)) {
watcher.on(type, (filename)=>{
if (!(0, _sources).isCompilableExtension(filename, cliOptions.extensions)) {
return;
}
const start = process.hrtime();
handle(filename1).then(async (result)=>{
handle(filename).then(async (result)=>{
if (!result) {
results.delete(filename1);
results.delete(filename);
return;
}
results.set(filename1, result);
results.set(filename, result);
util.assertCompilationResult(results, true);

@@ -204,1 +202,3 @@ await output(results.values());

}
//# sourceMappingURL=file.js.map

@@ -14,9 +14,7 @@ "use strict";

} else {
var newObj = {
};
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
};
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {

@@ -45,1 +43,3 @@ Object.defineProperty(newObj, key, desc);

});
//# sourceMappingURL=index.js.map

@@ -9,55 +9,2 @@ "use strict";

var _core = require("@swc/core");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const pkg = require("../../package.json");
let program;
const initProgram = ()=>{
program = new _commander.default.Command();
/* istanbul ignore next */ if (process.env.NODE_ENV === "test") {
program.exitOverride();
}
program.option("-f, --filename [filename]", "filename to use when reading from stdin - this will be used in source-maps, errors etc");
program.option("--config-file [path]", "Path to a .swcrc file to use");
program.option("--env-name [name]", "The name of the 'env' to use when loading configs and plugins. " + "Defaults to the value of SWC_ENV, or else NODE_ENV, or else 'development'.");
program.option("--no-swcrc", "Whether or not to look up .swcrc files");
program.option("--delete-dir-on-start", "Whether or not delete output directory on start");
program.option("--ignore [list]", "list of glob paths to **not** compile", collect);
program.option("--only [list]", "list of glob paths to **only** compile", collect);
program.option("-w, --watch", "Recompile files on changes");
program.option("-q, --quiet", "Suppress compilation output");
program.option("-s, --source-maps [true|false|inline|both]", "generate source maps", unstringify);
program.option("--source-map-target [string]", "set `file` on returned source map");
program.option("--source-file-name [string]", "set `sources[0]` on returned source map");
program.option("--source-root [filename]", "the root from which all sources are relative");
program.option("-o, --out-file [out]", "Compile all input files into a single file");
program.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
program.option("-D, --copy-files", "When compiling a directory copy over non-compilable files");
program.option("--include-dotfiles", "Include dotfiles when compiling and copying non-compilable files");
program.option("-C, --config <config>", "Override a config from .swcrc file. e.g. -C module.type=amd -C module.moduleId=hello", collect);
program.option("--sync", "Invoke swc synchronously. Useful for debugging.", collect);
program.option("--log-watch-compilation", "Log a message when a watched file is successfully compiled", true);
program.option("--extensions [list]", "Use specific extensions", collect);
program.version(`
@swc/cli: ${pkg.version}
@swc/core: ${_core.version}
`);
program.usage("[options] <files ...>");
};
exports.initProgram = initProgram;
function unstringify(val) {
try {
return JSON.parse(val);
} catch {
return val;
}
}
function collect(value, previousValue) {
// If the user passed the option with no value, like "babel file.js --presets", do nothing.
/* istanbul ignore next */ if (typeof value !== "string") return previousValue;
const values = value.split(",");
return previousValue ? previousValue.concat(values) : values;
}
function parserArgs(args) {

@@ -95,4 +42,3 @@ program.parse(args);

parser: undefined,
transform: {
}
transform: {}
},

@@ -125,4 +71,3 @@ sourceFileName: opts.sourceFileName,

if (options[keyPart] === undefined && index !== lastIndex) {
options[keyPart] = {
};
options[keyPart] = {};
}

@@ -156,1 +101,56 @@ if (index === lastIndex) {

}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const pkg = require("../../package.json");
let program;
const initProgram = ()=>{
program = new _commander.default.Command();
/* istanbul ignore next */ if (process.env.NODE_ENV === "test") {
program.exitOverride();
}
program.option("-f, --filename [filename]", "filename to use when reading from stdin - this will be used in source-maps, errors etc");
program.option("--config-file [path]", "Path to a .swcrc file to use");
program.option("--env-name [name]", "The name of the 'env' to use when loading configs and plugins. " + "Defaults to the value of SWC_ENV, or else NODE_ENV, or else 'development'.");
program.option("--no-swcrc", "Whether or not to look up .swcrc files");
program.option("--delete-dir-on-start", "Whether or not delete output directory on start");
program.option("--ignore [list]", "list of glob paths to **not** compile", collect);
program.option("--only [list]", "list of glob paths to **only** compile", collect);
program.option("-w, --watch", "Recompile files on changes");
program.option("-q, --quiet", "Suppress compilation output");
program.option("-s, --source-maps [true|false|inline|both]", "generate source maps", unstringify);
program.option("--source-map-target [string]", "set `file` on returned source map");
program.option("--source-file-name [string]", "set `sources[0]` on returned source map");
program.option("--source-root [filename]", "the root from which all sources are relative");
program.option("-o, --out-file [out]", "Compile all input files into a single file");
program.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
program.option("-D, --copy-files", "When compiling a directory copy over non-compilable files");
program.option("--include-dotfiles", "Include dotfiles when compiling and copying non-compilable files");
program.option("-C, --config <config>", "Override a config from .swcrc file. e.g. -C module.type=amd -C module.moduleId=hello", collect);
program.option("--sync", "Invoke swc synchronously. Useful for debugging.", collect);
program.option("--log-watch-compilation", "Log a message when a watched file is successfully compiled", true);
program.option("--extensions [list]", "Use specific extensions", collect);
program.version(`
@swc/cli: ${pkg.version}
@swc/core: ${_core.version}
`);
program.usage("[options] <files ...>");
};
exports.initProgram = initProgram;
function unstringify(val) {
try {
return JSON.parse(val);
} catch {
return val;
}
}
function collect(value, previousValue) {
// If the user passed the option with no value, like "babel file.js --presets", do nothing.
/* istanbul ignore next */ if (typeof value !== "string") return previousValue;
const values = value.split(",");
return previousValue ? previousValue.concat(values) : values;
}
//# sourceMappingURL=options.js.map

@@ -23,9 +23,7 @@ "use strict";

} else {
var newObj = {
};
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
};
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {

@@ -113,1 +111,3 @@ Object.defineProperty(newObj, key, desc);

}
//# sourceMappingURL=sources.js.map

@@ -22,9 +22,7 @@ "use strict";

} else {
var newObj = {
};
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
};
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {

@@ -69,6 +67,6 @@ Object.defineProperty(newObj, key, desc);

if (opts.sourceFileName) {
sourceMap['sources'][0] = opts.sourceFileName;
sourceMap["sources"][0] = opts.sourceFileName;
}
if (opts.sourceRoot) {
sourceMap['sourceRoot'] = opts.sourceRoot;
sourceMap["sourceRoot"] = opts.sourceRoot;
}

@@ -106,3 +104,3 @@ result.map = JSON.stringify(sourceMap);

failed++;
} else if (value === 'copied') {
} else if (value === "copied") {
copied++;

@@ -121,1 +119,3 @@ } else if (value) {

}
//# sourceMappingURL=util.js.map
{
"name": "@swc/cli",
"version": "0.1.55",
"version": "0.1.56",
"description": "CLI for the swc project",

@@ -5,0 +5,0 @@ "main": "lib/swc/index.js",

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

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

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