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

@a-la/import

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@a-la/import - npm Package Compare versions

Comparing version 1.10.0 to 1.10.1

18

build/lib/index.js

@@ -1,6 +0,8 @@

const getRequire = (quotes, src) => {
const { relative, dirname } = require('path');
const getRequire = (quotes, src) => {
return 'r' + `equire(${quotes}${src}${quotes})`
}
const getIfEsModule = (name) => {
const getIfEsModule = (name) => {
const s = `if (${name} && ${name}.__esModule) ${name} = ${name}.default`

@@ -10,3 +12,3 @@ return s

const getDefault = (name, req) => {
const getDefault = (name, req) => {
if (!name) return

@@ -18,3 +20,3 @@ const ifES = getIfEsModule(name)

const replaceRequire = (seg, quotes, src, defName = null) => {
const replaceRequire = (seg, quotes, src, defName = null) => {
const eq = seg.replace(/(\s+)from(\s+)([\s\S])*/, (m, b, a) => {

@@ -32,3 +34,3 @@ return `${b}=${a}`

*/
const getSource = (src, config = {}) => {
const getSource = (src, config = {}) => {
if (!config.import) return src

@@ -48,3 +50,3 @@ const { import: { replacement } } = config

// temp solution, until restream markers can store only part of regex, e.g. '%RESTREAM_MARKER%' instead of %RESTREAM_MARKER% for a string.
const fromRe = /(\s+from\s+)(?:%%_RESTREAM_STRINGS_REPLACEMENT_(\d+)_%%|%%_RESTREAM_LITERALS_REPLACEMENT_(\d+)_%%)/
const fromRe = /(\s+from\s+)(?:%%_RESTREAM_STRINGS_REPLACEMENT_(\d+)_%%|%%_RESTREAM_LITERALS_REPLACEMENT_(\d+)_%%)/

@@ -54,3 +56,3 @@ /**

*/
const alwaysCheckES = (config = {
const alwaysCheckES = (config = {
import: {},

@@ -68,3 +70,3 @@ }) => {

*/
const isAlamodeModule = (name, config = {
const isAlamodeModule = (name, config = {
import: {},

@@ -71,0 +73,0 @@ }) => {

@@ -5,4 +5,4 @@ const {

} = require('./');
let fpj = require('fpj'); if (fpj && fpj.__esModule) fpj = fpj.default;
const { dirname } = require('path');
const fpj = require('fpj');
const { dirname, relative } = require('path');
const { builtinModules } = require('module');

@@ -58,3 +58,16 @@

})
const source = getSource(s, this.config)
const stdlib = getStdlib(this.file, src, this.config)
const source = stdlib || getSource(s, this.config)
if (stdlib) {
if (!namedSeg) {
namedSeg = defSeg.replace(/(\S+)/, '{ $1 }')
defSeg = undefined
defName = undefined
} else if (defSeg) {
namedSeg = namedSeg.replace(/{/, `{ ${defName},`)
namedSeg = defSeg.replace(/\S/g, ' ') + namedSeg
defSeg = undefined
defName = undefined
} // if just named, leave as
}
if (!this.isLocalCache) this.isLocalCache = {}

@@ -71,2 +84,19 @@ if (this.async) {

/**
* @param {string} file Relative path to the current file
* @param {string} src Path to import.
* @param {Object} [config] ÀLaMode configuration.
*/
const getStdlib = (file, src, config = {}) => {
if (!config.import) return null
const { import: { stdlib } } = config
if (stdlib) {
const { packages, path } = stdlib
if (!packages.includes(src)) return null
const rel = relative(dirname(file), path).replace(/.js$/, '')
return rel
}
return null
}
const finish = (namedSeg, fromSeg, defSeg, defName, quotes, source, isLocal) => {

@@ -127,3 +157,2 @@ const { t, ifES } = getDef(defSeg, defName, quotes, source, isLocal)

/**

@@ -130,0 +159,0 @@ * @suppress {nonStandardJsDocs}

## 3 August 2019
### [1.10.1](https://github.com/a-la/import/compare/v1.10.0...v1.10.1)
- [fix] Keep imports unaffected by `stdlib`.
### [1.10.0](https://github.com/a-la/import/compare/v1.9.1...v1.10.0)

@@ -4,0 +8,0 @@

{
"name": "@a-la/import",
"version": "1.10.0",
"version": "1.10.1",
"description": "RegExp rules to transpile import statements into require calls (used in ÀLaMode).",

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

@@ -92,3 +92,3 @@ import {

const { packages, path } = stdlib
if (!packages.includes(src)) return src
if (!packages.includes(src)) return null
const rel = relative(dirname(file), path).replace(/.js$/, '')

@@ -95,0 +95,0 @@ return rel

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