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

scss-bundle

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scss-bundle - npm Package Compare versions

Comparing version 0.0.0-canary.53afdbe to 0.0.0-canary.650dc78

81

dist/bundler.js

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

return tslib_1.__awaiter(this, void 0, void 0, function () {
var dirname, importsPromises, imports, bundleResult, shouldCheckForDedupes, currentImports, _i, imports_1, imp, contentToReplace, currentImport, impContent, bundledImport, childImports, timesUsed;
var dirname, importsPromises, imports, bundleResult, shouldCheckForDedupes, currentImports, _i, imports_1, imp, contentToReplace, currentImport, impContent, _a, bundledImport, childImports, timesUsed;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:

@@ -115,3 +115,3 @@ // Remove commented imports

case 1:
imports = _a.sent();
imports = _b.sent();
bundleResult = {

@@ -124,5 +124,5 @@ filePath: filePath,

_i = 0, imports_1 = imports;
_a.label = 2;
_b.label = 2;
case 2:
if (!(_i < imports_1.length)) return [3 /*break*/, 9];
if (!(_i < imports_1.length)) return [3 /*break*/, 11];
imp = imports_1[_i];

@@ -139,21 +139,26 @@ contentToReplace = void 0;

};
return [3 /*break*/, 7];
return [3 /*break*/, 9];
case 3:
if (!(this.fileRegistry[imp.fullPath] == null)) return [3 /*break*/, 6];
if (!(this.usedImports[imp.fullPath] == null)) return [3 /*break*/, 8];
// Add it to used imports
this.usedImports[imp.fullPath] = 1;
if (!(this.fileRegistry[imp.fullPath] == null)) return [3 /*break*/, 5];
return [4 /*yield*/, fs_extra_1.default.readFile(imp.fullPath, "utf-8")];
case 4:
impContent = _a.sent();
_a = _b.sent();
return [3 /*break*/, 6];
case 5:
_a = this.fileRegistry[imp.fullPath];
_b.label = 6;
case 6:
impContent = _a;
return [4 /*yield*/, this._bundle(imp.fullPath, impContent, dedupeFiles, includePaths, ignoredImports)];
case 5:
bundledImport = _a.sent();
case 7:
bundledImport = _b.sent();
// Then add its bundled content to the registry
this.fileRegistry[imp.fullPath] = bundledImport.bundledContent;
// Add it to used imports, if it's not there
if (this.usedImports != null && this.usedImports[imp.fullPath] == null) {
this.usedImports[imp.fullPath] = 1;
}
// And whole BundleResult to current imports
currentImport = bundledImport;
return [3 /*break*/, 7];
case 6:
return [3 /*break*/, 9];
case 8:
// File is in the registry

@@ -175,4 +180,4 @@ // Increment it's usage count

};
_a.label = 7;
case 7:
_b.label = 9;
case 9:
if (imp.ignored) {

@@ -209,7 +214,7 @@ if (this.usedImports[imp.fullPath] > 1) {

currentImports.push(currentImport);
_a.label = 8;
case 8:
_b.label = 10;
case 10:
_i++;
return [3 /*break*/, 2];
case 9:
case 11:
// Set result properties

@@ -244,9 +249,15 @@ bundleResult.bundledContent = content;

case 0:
_a.trys.push([0, 2, , 7]);
if (this.fileRegistry[importData.fullPath]) {
importData.found = true;
return [2 /*return*/, importData];
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 8]);
return [4 /*yield*/, fs_extra_1.default.access(importData.fullPath)];
case 1:
case 2:
_a.sent();
importData.found = true;
return [3 /*break*/, 7];
case 2:
return [3 /*break*/, 8];
case 3:
error_1 = _a.sent();

@@ -256,12 +267,12 @@ underscoredDirname = path_1.default.dirname(importData.fullPath);

underscoredFilePath = path_1.default.join(underscoredDirname, "_" + underscoredBasename);
_a.label = 3;
case 3:
_a.trys.push([3, 5, , 6]);
_a.label = 4;
case 4:
_a.trys.push([4, 6, , 7]);
return [4 /*yield*/, fs_extra_1.default.access(underscoredFilePath)];
case 4:
case 5:
_a.sent();
importData.fullPath = underscoredFilePath;
importData.found = true;
return [3 /*break*/, 6];
case 5:
return [3 /*break*/, 7];
case 6:
underscoreErr_1 = _a.sent();

@@ -275,5 +286,5 @@ // If there are any includePaths

}
return [3 /*break*/, 6];
case 6: return [3 /*break*/, 7];
case 7: return [2 /*return*/, importData];
return [3 /*break*/, 7];
case 7: return [3 /*break*/, 8];
case 8: return [2 /*return*/, importData];
}

@@ -280,0 +291,0 @@ });

import commander from "commander";
import { BundlerOptions } from "../contracts";
export interface Arguments extends BundlerOptions {
project: string;
config?: string;
}
export declare function resolveArguments(cmd: commander.Command, argv: string[]): Arguments;

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

var parsedArguments = cmd
.option("-p, --project <path>", "project location where 'scss-bundle.config.json' and 'node_modules' are located", helpers_1.resolvePath, process.cwd())
.option("-c, --config <path>", "configuration file location", helpers_1.resolvePath)
.option("-p, --project <path>", "project location where 'node_modules' folder is located", helpers_1.resolvePath)
.option("-e, --entryFile <path>", "bundle entry file location", helpers_1.resolvePath)

@@ -18,4 +19,5 @@ .option("-o, --outFile <path>", "bundle output location", helpers_1.resolvePath)

.parse(argv);
var project = parsedArguments.project, entryFile = parsedArguments.entryFile, ignoreImports = parsedArguments.ignoreImports, includePaths = parsedArguments.includePaths, outFile = parsedArguments.outFile, rootDir = parsedArguments.rootDir, watch = parsedArguments.watch, logLevel = parsedArguments.logLevel;
var config = parsedArguments.config, project = parsedArguments.project, entryFile = parsedArguments.entryFile, ignoreImports = parsedArguments.ignoreImports, includePaths = parsedArguments.includePaths, outFile = parsedArguments.outFile, rootDir = parsedArguments.rootDir, watch = parsedArguments.watch, logLevel = parsedArguments.logLevel;
return {
config: config,
project: project,

@@ -22,0 +24,0 @@ entryFile: entryFile,

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

return [2 /*return*/, {
bundlerOptions: tslib_1.__assign({}, json.bundlerOptions, { entryFile: json.bundlerOptions.entryFile != null ? helpers_1.resolvePath(json.bundlerOptions.entryFile) : undefined, outFile: json.bundlerOptions.outFile != null ? helpers_1.resolvePath(json.bundlerOptions.outFile) : undefined, rootDir: json.bundlerOptions.rootDir != null ? helpers_1.resolvePath(json.bundlerOptions.rootDir) : undefined })
bundlerOptions: tslib_1.__assign(tslib_1.__assign({}, json.bundlerOptions), { entryFile: json.bundlerOptions.entryFile != null ? helpers_1.resolvePath(json.bundlerOptions.entryFile) : undefined, outFile: json.bundlerOptions.outFile != null ? helpers_1.resolvePath(json.bundlerOptions.outFile) : undefined, rootDir: json.bundlerOptions.rootDir != null ? helpers_1.resolvePath(json.bundlerOptions.rootDir) : undefined })
}];

@@ -29,0 +29,0 @@ }

@@ -0,1 +1,2 @@

#!/usr/bin/env node
export {};

@@ -0,1 +1,2 @@

#!/usr/bin/env node
"use strict";

@@ -46,3 +47,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

fileRegistry = {};
bundler = new bundler_1.Bundler(fileRegistry, config.rootDir);
bundler = new bundler_1.Bundler(fileRegistry, project);
return [4 /*yield*/, bundler.bundle(config.entryFile, config.dedupeGlobs, config.includePaths, config.ignoreImports)];

@@ -55,4 +56,4 @@ case 1:

bundleResultForEach(bundleResult, function (result) {
if (!result.found && result.tilde && config.rootDir == null) {
logging_1.Log.warn("Found tilde import, but rootDir was not specified.");
if (!result.found && result.tilde && project == null) {
logging_1.Log.warn("Found tilde import, but \"project\" was not specified.");
throw new import_file_not_found_error_1.ImportFileNotFoundError(result.filePath);

@@ -82,40 +83,62 @@ }

function main(argv) {
var _a, _b;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var packageJson, cliOptions, stats, configPath, project, config, jsonConfig, error_1, resolvedLogLevel, logLevelKey, onFileChange, watchFolder, _a, fileRegistry, bundleResult, error_2;
var packageJson, cliOptions, configLocation, stats, projectLocation, stats, config, jsonConfig, error_1, configLocationDir, resolvedLogLevel, logLevelKey, onFileChange, watchFolder, _c, fileRegistry, bundleResult, error_2;
var _this = this;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
return tslib_1.__generator(this, function (_d) {
switch (_d.label) {
case 0: return [4 /*yield*/, fs_extra_1.default.readJson(PACKAGE_JSON_PATH)];
case 1:
packageJson = _b.sent();
packageJson = _d.sent();
cliOptions = arguments_1.resolveArguments(commander_1.default.version(packageJson.version, "-v, --version"), argv);
return [4 /*yield*/, fs_extra_1.default.stat(cliOptions.project)];
if (!(cliOptions.config != null)) return [3 /*break*/, 3];
return [4 /*yield*/, fs_extra_1.default.stat(cliOptions.config)];
case 2:
stats = _b.sent();
stats = _d.sent();
if (stats.isDirectory()) {
configPath = path_1.default.resolve(cliOptions.project, constants_1.CONFIG_FILE_NAME);
configLocation = path_1.default.resolve(cliOptions.config, constants_1.CONFIG_FILE_NAME);
}
else {
configPath = cliOptions.project;
configLocation = cliOptions.config;
}
project = path_1.default.dirname(configPath);
if (!(configPath != null)) return [3 /*break*/, 7];
_b.label = 3;
_d.label = 3;
case 3:
_b.trys.push([3, 5, , 6]);
return [4 /*yield*/, config_1.resolveConfig(configPath)];
if (!(cliOptions.project != null)) return [3 /*break*/, 5];
return [4 /*yield*/, fs_extra_1.default.stat(cliOptions.project)];
case 4:
jsonConfig = _b.sent();
stats = _d.sent();
if (stats.isDirectory()) {
projectLocation = cliOptions.project;
}
else {
logging_1.Log.warn("[DEPRECATED]: Flag \"project\" pointing to the config file directly is deprecated. Provide a path to the directory where the project is.");
configLocation = cliOptions.project;
projectLocation = path_1.default.dirname(cliOptions.project);
}
_d.label = 5;
case 5:
if (!(configLocation != null)) return [3 /*break*/, 10];
_d.label = 6;
case 6:
_d.trys.push([6, 8, , 9]);
return [4 /*yield*/, config_1.resolveConfig(configLocation)];
case 7:
jsonConfig = _d.sent();
config = helpers_1.mergeObjects(jsonConfig.bundlerOptions, cliOptions);
return [3 /*break*/, 6];
case 5:
error_1 = _b.sent();
return [3 /*break*/, 9];
case 8:
error_1 = _d.sent();
logging_1.Log.error(error_1);
process.exit(1);
return [2 /*return*/];
case 6: return [3 /*break*/, 8];
case 7:
return [3 /*break*/, 9];
case 9: return [3 /*break*/, 11];
case 10:
config = cliOptions;
_b.label = 8;
case 8:
_d.label = 11;
case 11:
// Resolve project location from config file.
if (projectLocation == null && configLocation != null) {
configLocationDir = path_1.default.dirname(configLocation);
projectLocation = path_1.default.resolve(configLocationDir, (_a = config.project, (_a !== null && _a !== void 0 ? _a : "./")));
}
if (config.logLevel != null) {

@@ -129,3 +152,3 @@ logLevelKey = helpers_1.resolveLogLevelKey(config.logLevel);

logging_1.Log.setLevel(resolvedLogLevel == null ? constants_1.LogLevel.Info : resolvedLogLevel);
if (!config.watch) return [3 /*break*/, 9];
if (!config.watch) return [3 /*break*/, 12];
onFileChange = lodash_debounce_1.default(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {

@@ -136,3 +159,3 @@ return tslib_1.__generator(this, function (_a) {

logging_1.Log.info("File changes detected.");
return [4 /*yield*/, build(project, config)];
return [4 /*yield*/, build(projectLocation, config)];
case 1:

@@ -145,21 +168,24 @@ _a.sent();

}); });
watchFolder = config.rootDir != null ? config.rootDir : project;
if (!config.rootDir) {
logging_1.Log.warn("rootDir property is missing in config, using current working directory: " + process.cwd());
}
watchFolder = (_b = config.rootDir, (_b !== null && _b !== void 0 ? _b : process.cwd()));
logging_1.Log.info("Waiting for changes...");
chokidar_1.default.watch(watchFolder).on("change", onFileChange);
return [3 /*break*/, 12];
case 9:
_b.trys.push([9, 11, , 12]);
return [4 /*yield*/, build(project, config)];
case 10:
_a = _b.sent(), fileRegistry = _a.fileRegistry, bundleResult = _a.bundleResult;
return [3 /*break*/, 15];
case 12:
_d.trys.push([12, 14, , 15]);
return [4 /*yield*/, build(projectLocation, config)];
case 13:
_c = _d.sent(), fileRegistry = _c.fileRegistry, bundleResult = _c.bundleResult;
logging_1.Log.info("Imports tree:");
logging_1.Log.info(archy_1.renderArchy(bundleResult, project));
logging_1.Log.info(archy_1.renderArchy(bundleResult, projectLocation));
logging_1.Log.info(bundle_info_1.renderBundleInfo(bundleResult, fileRegistry));
return [3 /*break*/, 12];
case 11:
error_2 = _b.sent();
return [3 /*break*/, 15];
case 14:
error_2 = _d.sent();
logging_1.Log.error(error_2.message);
process.exit(1);
return [3 /*break*/, 12];
case 12: return [2 /*return*/];
return [3 /*break*/, 15];
case 15: return [2 /*return*/];
}

@@ -166,0 +192,0 @@ });

@@ -1,1 +0,1 @@

export declare function renderScss(projectPath: string, includePaths: string[] | undefined, content: string): Promise<{}>;
export declare function renderScss(projectPath: string | undefined, includePaths: string[] | undefined, content: string): Promise<{}>;

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

data: content,
importer: sassImporter(projectPath),
importer: projectPath != null ? sassImporter(projectPath) : undefined,
includePaths: includePaths

@@ -29,0 +29,0 @@ }, function (error, result) {

@@ -5,2 +5,3 @@ export interface ScssBundleConfig {

export interface BundlerOptions {
project?: string;
entryFile?: string;

@@ -7,0 +8,0 @@ outFile?: string;

{
"name": "scss-bundle",
"version": "0.0.0-canary.53afdbe",
"version": "0.0.0-canary.650dc78",
"description": "Bundling SCSS files to one bundled file.",

@@ -23,3 +23,3 @@ "main": "dist/index.js",

"dist",
"**/*.md",
"docs",
"*.js",

@@ -37,10 +37,10 @@ "!*.config.js"

"devDependencies": {
"@types/jest": "^24.0.17",
"jest": "^24.8.0",
"ts-jest": "^24.0.2",
"@types/jest": "^24.0.23",
"jest": "^24.9.0",
"ts-jest": "^24.2.0",
"@reactway/eslint-config": "^1.0.0-alpha.2",
"eslint": "^6.1.0",
"typescript": "^3.5.3",
"eslint": "^6.7.2",
"typescript": "^3.7.3",
"@simplrjs/test-generator-cli": "^0.1.3",
"jest-junit": "^7.0.0"
"jest-junit": "^10.0.0"
},

@@ -50,3 +50,3 @@ "dependencies": {

"@types/debug": "^4.1.5",
"@types/fs-extra": "^8.0.0",
"@types/fs-extra": "^8.0.1",
"@types/glob": "^7.1.1",

@@ -56,12 +56,12 @@ "@types/lodash.debounce": "^4.0.6",

"archy": "^1.0.0",
"chalk": "^2.4.2",
"chokidar": "^3.0.2",
"commander": "^3.0.0",
"chalk": "^3.0.0",
"chokidar": "^3.3.1",
"commander": "^4.0.1",
"fs-extra": "^8.1.0",
"globs": "^0.1.4",
"lodash.debounce": "^4.0.8",
"loglevel": "^1.6.3",
"loglevel": "^1.6.6",
"loglevel-plugin-prefix": "^0.8.4",
"pretty-bytes": "^5.3.0",
"sass": "^1.22.9",
"sass": "^1.23.7",
"tslib": "^1.10.0"

@@ -68,0 +68,0 @@ },

@@ -17,3 +17,3 @@ # scss-bundle

A few of the projects who use the package:
#### Projects

@@ -23,2 +23,6 @@ - [Angular/material2](https://github.com/angular/material2)

#### Community plugins
- [rollup-plugin-bundle-scss](https://github.com/weizhenye/rollup-plugin-bundle-scss)
## Get started

@@ -56,13 +60,14 @@

| CLI Flag | Bundler options | Type | Description | Values | Default |
| --------------------------------------- | ------------------------ | -------- | -------------------------------------------------------------------------------- | ------------------------------------------ | ------- |
| -p, --project \<path\> | | string | Project location where `scss-bundle.config.json` and `node_modules` are located. | | _cwd_ |
| -e, --entryFile \<path\> <sup>`*`</sup> | entryFile <sup>`*`</sup> | string | Bundle entry file location. | | |
| -o, --outFile \<path\> <sup>`*`</sup> | outFile <sup>`*`</sup> | string | Bundle output location. | | |
| --rootDir \<path\> | rootDir | string | Specifies the root directory of input files. | | |
| -w, --watch [boolean] | watch | boolean | Watch files for changes. Works with `rootDir`. | | |
| --ignoreImports \<list\> | ignoreImports | string[] | Ignore resolving import content by matching a regular expression. | | |
| --includePaths \<list\> | includePaths | string[] | Include paths for resolving imports. | | |
| --dedupeGlobs \<list\> | dedupeGlobs | string[] | Files that will be emitted in a bundle once. | | |
| --logLevel \<level\> | logLevel | string | Console log level. | silent, error, warning, info, debug, trace | info |
| CLI Flag | Bundler options | Type | Description | Values | Default |
| --------------------------------------- | ------------------------ | -------- | ----------------------------------------------------------------- | ------------------------------------------ | ------- |
| -c, --config \<path\> | | string | Configuration file location. | | |
| -p, --project \<path\> | project | string | Project location where `node_modules` is located. | | |
| -e, --entryFile \<path\> <sup>`*`</sup> | entryFile <sup>`*`</sup> | string | Bundle entry file location. | | |
| -o, --outFile \<path\> <sup>`*`</sup> | outFile <sup>`*`</sup> | string | Bundle output location. | | |
| --rootDir \<path\> | rootDir | string | Specifies the root directory of input files. | | |
| -w, --watch [boolean] | watch | boolean | Watch files for changes. Works with `rootDir`. | | |
| --ignoreImports \<list\> | ignoreImports | string[] | Ignore resolving import content by matching a regular expression. | | |
| --includePaths \<list\> | includePaths | string[] | Include paths for resolving imports. | | |
| --dedupeGlobs \<list\> | dedupeGlobs | string[] | Files that will be emitted in a bundle once. | | |
| --logLevel \<level\> | logLevel | string | Console log level. | silent, error, warning, info, debug, trace | info |

@@ -69,0 +74,0 @@ `*` - Required

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