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.6.2 to 1.7.0

6

build/index.js

@@ -1,7 +0,4 @@

const { debuglog } = require('util');
let rule = require('./lib/rule'); if (rule && rule.__esModule) rule = rule.default;
let importAs = require('./lib/import-as'); if (importAs && importAs.__esModule) importAs = importAs.default;
const LOG = debuglog('@a-la/import')
/**

@@ -15,3 +12,2 @@ * An À La Sequence to combine multiple rules from this package (such as `import defaultFn`, `import { namedFn }`, _etc_).

module.exports=seq
//# sourceMappingURL=index.js.map
module.exports=seq

13

build/lib/import-as.js

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

const { replaceRequire, fromRe, getIfEsModule } = require('.');
const { replaceRequire, fromRe, getIfEsModule, alwaysCheckES } = require('.');

@@ -6,4 +6,3 @@ const importRe = /( *import\s+(?:(.+?)\s*,\s*)?\*\s+as\s+(.+?))/

const importAs =
{
const importAs = {
re,

@@ -19,6 +18,8 @@ replacement(match, importSeg, defName, varName, fromSeg, sd, ld) {

let c
const isLocal = /^[./]/.test(src) && !alwaysCheckES(this.config)
const o = isLocal ? 'const' : 'let'
if (defName) {
c = [
`${ws}let ${varName} = ${defName}${r}`,
getIfEsModule(defName),
`${ws}${o} ${varName} = ${defName}${r}`,
...(isLocal ? [] : [getIfEsModule(defName)]),
].join('; ')

@@ -33,3 +34,1 @@ } else {

module.exports=importAs
//# sourceMappingURL=import-as.js.map

@@ -26,2 +26,5 @@ const getRequire = (quotes, src) => {

/**
* @param {string} src
*/
const getSource = (src, config = {}) => {

@@ -31,4 +34,6 @@ const { import: { replacement } = {} } = config

const { from, to } = replacement
if (from === undefined) throw new Error('No "from" is given option is given for the replacement.')
if (to === undefined ) throw new Error('No "to" is given option is given for the replacement.')
if (from === undefined)
throw new Error('No "from" is given option is given for the replacement.')
if (to === undefined )
throw new Error('No "to" is given option is given for the replacement.')
const fromRe = new RegExp(replacement.from)

@@ -42,2 +47,10 @@ const res = src.replace(fromRe, replacement.to)

const alwaysCheckES = (config = {}) => {
try {
return config.import.esCheck == 'always'
} catch (err) {
return false
}
}
module.exports.getRequire = getRequire

@@ -49,2 +62,2 @@ module.exports.getIfEsModule = getIfEsModule

module.exports.fromRe = fromRe
//# sourceMappingURL=index.js.map
module.exports.alwaysCheckES = alwaysCheckES
const {
getRequire, getDefault, getSource, replaceRequire, fromRe,
getRequire, getDefault, getSource, replaceRequire, fromRe, alwaysCheckES,
} = require('.');

@@ -45,8 +45,7 @@

const source = getSource(s, this.config)
const { t, ifES } = getDef(defSeg, defName, quotes, source)
const isLocal = /^[./]/.test(source) && !alwaysCheckES(this.config)
const { t, ifES } = getDef(defSeg, defName, quotes, source, isLocal)
const replacedNamed = getNamed(namedSeg, fromSeg, quotes, source, defName)
const res = [
t,
replacedNamed,
ifES,
t, replacedNamed, ...(isLocal ? [] : [ifES]),
]

@@ -59,3 +58,3 @@ .filter(a => a)

const getDef = (defSeg, defName, quotes, src) => {
const getDef = (defSeg, defName, quotes, src, isLocal) => {
if (!defSeg) return {}

@@ -65,3 +64,4 @@ const req = getRequire(quotes, src)

const s = replaceDefault(defSeg, d)
const t = `let${s}`
const o = isLocal ? 'const' : 'let'
const t = `${o}${s}`
return { t, ifES }

@@ -81,3 +81,2 @@ }

module.exports.re = re
//# sourceMappingURL=rule.js.map
module.exports.re = re

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

## 8 October 2018
### 1.7.0
- [feature] Do not add the `__esModule` check to modules imported locally.
## 20 September 2018

@@ -2,0 +8,0 @@

{
"name": "@a-la/import",
"version": "1.6.2",
"version": "1.7.0",
"description": "À La Regex to transpile the import statement into a require call.",

@@ -20,3 +20,3 @@ "main": "build",

"build": "yarn-s b doc",
"b": "alamode src -o build"
"b": "alamode src -o build -s"
},

@@ -62,11 +62,13 @@ "files": [

"@a-la/context": "1.2.3",
"alamode": "1.5.0",
"@a-la/fixture-alamode": "1.0.0",
"@a-la/fixture-babel": "1.0.0",
"alamode": "1.5.1",
"catchment": "3.1.1",
"documentary": "1.18.0",
"documentary": "1.20.1",
"eslint-config-artdeco": "1.0.1",
"restream": "3.2.1",
"yarn-s": "1.1.0",
"zoroaster": "3.5.0"
"zoroaster": "3.6.2"
},
"dependencies": {}
}

@@ -51,2 +51,3 @@ # @a-la/import

import App from 'koa'
import test from './test'
`

@@ -65,2 +66,3 @@

let App = require('koa'); if (App && App.__esModule) App = App.default;
const test = require('./test');
```

@@ -70,18 +72,31 @@

The transform accepts a single `replacement` option via the `.alamoderc` to be able to substitute the name or path of an imported module.
The transform accepts a number of options via the `.alamoderc`.
```json
{
"env": {
"test-build": {
"import": {
"replacement": {
"from": "^((../)+)src",
"to": "$1build"
- `replacement` option is used to substitute the name or path of an imported module.
```json5
{
"env": {
"test-build": {
"import": {
"replacement": {
"from": "^((../)+)src",
"to": "$1build"
}
}
}
}
}
}
}
```
```
- `esCheck` option is used to always enforce the `if (mod.__esModule)` check -- by default, this is switched off for local imports, but is added when requiring external packages to make it compatible with _Babel_ and _TypeScript_.
```json5
{
"env": {
"test-build": {
"import": {
"esCheck": "always",
}
}
}
}
```

@@ -119,3 +134,3 @@ <p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/2.svg?sanitize=true"></a></p>

let tests = def = require('./tests'); if (def && def.__esModule) def = def.default;
const tests = def = require('./tests');
```

@@ -122,0 +137,0 @@

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