New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mattsjones/css-babel-plugin

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mattsjones/css-babel-plugin - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

3

dist/declarations/src/index.d.ts

@@ -13,2 +13,3 @@ import { PluginObj, PluginPass } from '@babel/core';

alias?: string;
projectRoot?: string;
}

@@ -19,4 +20,6 @@ declare type Context = PluginPass & {

importIdentifiers: Map<string, RelevantExport>;
packageIdentifier: string;
fileScope: string;
};
export default function (): PluginObj<Context>;
export {};

@@ -5,4 +5,14 @@ 'use strict';

var path = require('path');
var core = require('@babel/core');
var template = require('@babel/template');
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
var template__default = /*#__PURE__*/_interopDefault(template);
const buildSetFileScope = template__default['default'](`
import { setFileScope, endFileScope } from %%packageIdentifier%%
setFileScope(%%fileScope%%)
`);
const exportConfig = {

@@ -77,4 +87,6 @@ style: {

return {
pre() {
var _this$opts;
pre({
opts
}) {
var _this$opts, _this$opts2;

@@ -84,5 +96,32 @@ this.importIdentifiers = new Map();

this.packageIdentifier = ((_this$opts = this.opts) === null || _this$opts === void 0 ? void 0 : _this$opts.alias) || '@mattsjones/css-core';
const projectRoot = ((_this$opts2 = this.opts) === null || _this$opts2 === void 0 ? void 0 : _this$opts2.projectRoot) || opts.root;
if (!projectRoot) {
// TODO Make error better
throw new Error('Project root must be specified');
}
if (!opts.filename) {
// TODO Make error better
throw new Error('Filename must be available');
}
this.fileScope = path.relative(projectRoot, opts.filename);
},
visitor: {
Program: {
exit(path) {
if (this.importIdentifiers.size > 0 || this.namespaceImport) {
// Wrap module with file scope calls
path.unshiftContainer('body', buildSetFileScope({
packageIdentifier: core.types.stringLiteral(`${this.packageIdentifier}/fileScope`),
fileScope: core.types.stringLiteral(this.fileScope)
}));
path.pushContainer('body', core.types.callExpression(core.types.identifier('endFileScope'), []));
}
}
},
ImportDeclaration(path) {

@@ -89,0 +128,0 @@ if (path.node.source.value === this.packageIdentifier) {

@@ -5,4 +5,14 @@ 'use strict';

var path = require('path');
var core = require('@babel/core');
var template = require('@babel/template');
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
var template__default = /*#__PURE__*/_interopDefault(template);
const buildSetFileScope = template__default['default'](`
import { setFileScope, endFileScope } from %%packageIdentifier%%
setFileScope(%%fileScope%%)
`);
const exportConfig = {

@@ -77,4 +87,6 @@ style: {

return {
pre() {
var _this$opts;
pre({
opts
}) {
var _this$opts, _this$opts2;

@@ -84,5 +96,32 @@ this.importIdentifiers = new Map();

this.packageIdentifier = ((_this$opts = this.opts) === null || _this$opts === void 0 ? void 0 : _this$opts.alias) || '@mattsjones/css-core';
const projectRoot = ((_this$opts2 = this.opts) === null || _this$opts2 === void 0 ? void 0 : _this$opts2.projectRoot) || opts.root;
if (!projectRoot) {
// TODO Make error better
throw new Error('Project root must be specified');
}
if (!opts.filename) {
// TODO Make error better
throw new Error('Filename must be available');
}
this.fileScope = path.relative(projectRoot, opts.filename);
},
visitor: {
Program: {
exit(path) {
if (this.importIdentifiers.size > 0 || this.namespaceImport) {
// Wrap module with file scope calls
path.unshiftContainer('body', buildSetFileScope({
packageIdentifier: core.types.stringLiteral(`${this.packageIdentifier}/fileScope`),
fileScope: core.types.stringLiteral(this.fileScope)
}));
path.pushContainer('body', core.types.callExpression(core.types.identifier('endFileScope'), []));
}
}
},
ImportDeclaration(path) {

@@ -89,0 +128,0 @@ if (path.node.source.value === this.packageIdentifier) {

@@ -0,3 +1,9 @@

import { relative } from 'path';
import { types } from '@babel/core';
import template from '@babel/template';
const buildSetFileScope = template(`
import { setFileScope, endFileScope } from %%packageIdentifier%%
setFileScope(%%fileScope%%)
`);
const exportConfig = {

@@ -72,4 +78,6 @@ style: {

return {
pre() {
var _this$opts;
pre({
opts
}) {
var _this$opts, _this$opts2;

@@ -79,5 +87,32 @@ this.importIdentifiers = new Map();

this.packageIdentifier = ((_this$opts = this.opts) === null || _this$opts === void 0 ? void 0 : _this$opts.alias) || '@mattsjones/css-core';
const projectRoot = ((_this$opts2 = this.opts) === null || _this$opts2 === void 0 ? void 0 : _this$opts2.projectRoot) || opts.root;
if (!projectRoot) {
// TODO Make error better
throw new Error('Project root must be specified');
}
if (!opts.filename) {
// TODO Make error better
throw new Error('Filename must be available');
}
this.fileScope = relative(projectRoot, opts.filename);
},
visitor: {
Program: {
exit(path) {
if (this.importIdentifiers.size > 0 || this.namespaceImport) {
// Wrap module with file scope calls
path.unshiftContainer('body', buildSetFileScope({
packageIdentifier: types.stringLiteral(`${this.packageIdentifier}/fileScope`),
fileScope: types.stringLiteral(this.fileScope)
}));
path.pushContainer('body', types.callExpression(types.identifier('endFileScope'), []));
}
}
},
ImportDeclaration(path) {

@@ -84,0 +119,0 @@ if (path.node.source.value === this.packageIdentifier) {

5

package.json
{
"name": "@mattsjones/css-babel-plugin",
"version": "0.0.2",
"version": "0.0.3",
"main": "dist/mattsjones-css-babel-plugin.cjs.js",

@@ -17,5 +17,6 @@ "module": "dist/mattsjones-css-babel-plugin.esm.js",

"dependencies": {
"@babel/core": "^7.12.10"
"@babel/core": "^7.12.10",
"@babel/template": "^7.12.13"
},
"devDependencies": {}
}
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