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

babel-plugin-inline-json-import

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-inline-json-import - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

6

build/index.js

@@ -18,2 +18,4 @@ 'use strict';

var SUPPORTED_MODULES_REGEX = /\.json(!json)?$/;
function babelPluginInlineJsonImports(_ref) {

@@ -31,3 +33,3 @@ var t = _ref.types;

if (moduleName.match(/\.json(!json)?$/)) {
if (moduleName.match(SUPPORTED_MODULES_REGEX)) {
var leftExpression = determineLeftExpression(t, node);

@@ -52,3 +54,3 @@

if (init != null && init.type === 'CallExpression' && init.callee.type === 'Identifier' && init.callee.name === 'require' && init.arguments.length === 1 && init.arguments[0].type === 'StringLiteral') {
if (init != null && init.type === 'CallExpression' && init.callee.type === 'Identifier' && init.callee.name === 'require' && init.arguments.length === 1 && init.arguments[0].type === 'StringLiteral' && init.arguments[0].value.match(SUPPORTED_MODULES_REGEX)) {
changed = true;

@@ -55,0 +57,0 @@

{
"name": "babel-plugin-inline-json-import",
"version": "0.3.1",
"version": "0.3.2",
"description": "Inlines JSON file imports straight into JS code",

@@ -13,5 +13,5 @@ "main": "build/index.js",

"babel-preset-es2015": "^6.24.1",
"chai": "^3.5.0",
"mocha": "^3.5.3",
"tmp": "^0.0.29"
"chai": "^4.2.0",
"mocha": "^6.0.2",
"tmp": "^0.0.33"
},

@@ -34,4 +34,4 @@ "scripts": {

"dependencies": {
"decache": "^4.4.0"
"decache": "^4.5.1"
}
}

@@ -142,2 +142,24 @@ import fs from 'fs'

it('correctly ignores non-JSON files', () => {
const t = configureTransform()
const result = t(`
import json from '../test/fixtures/example.json'
import abc from 'abc'
import { a, b } from './foo.mp3';
const file = require('../src/index.js')
const example = require('./example')
`)
expect(normalize(result.code)).to.equal(normalize(`
const json = { example: true }
import abc from 'abc'
import { a, b } from './foo.mp3';
const file = require('../src/index.js')
const example = require('./example')
`))
})
function configureTransform(options = {}, isFile) {

@@ -144,0 +166,0 @@ return function configuredTransform(string) {

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