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

@idio/frontend

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@idio/frontend - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

build/lib/index.js

67

build/index.js

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

const { collect } = require('catchment');
const { Replaceable } = require('restream');
let read = require('@wrote/read'); if (read && read.__esModule) read = read.default;
const { relative, join, dirname } = require('path');
let transpileJSX = require('@a-la/jsx'); if (transpileJSX && transpileJSX.__esModule) transpileJSX = transpileJSX.default;
let resolveDependency = require('resolve-dependency'); if (resolveDependency && resolveDependency.__esModule) resolveDependency = resolveDependency.default;
let exists = require('@wrote/exists'); if (exists && exists.__esModule) exists = exists.default;
const { patchSource } = require('./lib');

@@ -27,5 +25,8 @@ /**

const p = ctx.path.replace('/', '')
if (p == directory || p.startsWith(`${directory}/`)) {
if ( p == directory
|| p.startsWith(`${directory}/`)
|| p.startsWith('node_modules/'))
{
const { path, isDir } = await resolveDependency(p)
if (isDir) {
if (isDir && !p.endsWith('/')) {
ctx.redirect(`/${path}`)

@@ -38,7 +39,2 @@ return

ctx.body = body
} else if (p.startsWith('node_modules/')) {
let body = await read(p)
body = await patch(p, body, pragma)
ctx.body = body
ctx.type = 'application/javascript'
} else {

@@ -80,54 +76,3 @@ await next()

const patchSource = async (path, source) => {
const replacement = async (m, pre, from) => {
if (/^[/.]/.test(from)) {
const dir = dirname(path)
const p = join(dir, from)
const { path: rd } = await resolveDependency(p)
const rel = relative(dir, rd)
const r = rel.startsWith('.') ? rel : `./${rel}`
return `${pre}'${r}'`
}
let [scope, name, ...paths] = from.split('/')
if (!scope.startsWith('@') && name) {
paths = [name, ...paths]
name = scope
} else {
name = `${scope}/${name}`
}
if (paths.length) {
return getNodeModule(name, paths.join('/'), pre)
}
const { module: mod } = require(`${from}/package.json`)
if (!mod) {
console.warn('[↛] Package %s does not specify module in package.json, trying src', from)
const d = getNodeModule(from, 'src', pre)
return d
}
return getNodeModule(from, mod, pre)
}
const rs = new Replaceable([
{
re: /^( *import(?:\s+[^\s,]+\s*,?)?(?:\s*{(?:[^}]+)})?\s+from\s+)['"](.+)['"]/gm,
replacement,
},
{
re: /^( *import\s+)['"](.+)['"]/gm,
replacement,
},
])
rs.end(source)
const body = await collect(rs)
return body
}
/**
* Returns the import statement with the path to the dependency on the file system.
*/
const getNodeModule = (from, path, pre) => {
const modPath = require.resolve(`${from}/${path}`)
const modRel = relative('', modPath)
return `${pre}'/${modRel}'`
}
/* documentary types/index.xml */

@@ -134,0 +79,0 @@ /**

## 8 February 2019
### 1.4.0
- [feature] Resolve `node_modules` entries.
- [feature] Resolve using FindPackageJson instead of `require.resolve` to serve linked packages.
- [fix] Don't override local dependencies' paths.
## 8 February 2019
### 1.3.0

@@ -4,0 +12,0 @@

{
"name": "@idio/frontend",
"version": "1.3.0",
"version": "1.4.0",
"description": "The Middleware To Serve Front-End JavaScript.",

@@ -35,3 +35,7 @@ "main": "build/index.js",

"jsx",
"node_modules"
"node_modules",
"browser",
"development",
"dev",
"middleware"
],

@@ -62,2 +66,3 @@ "author": "Anton <anton@adc.sh>",

"catchment": "3.2.2",
"fpj": "1.0.0",
"resolve-dependency": "1.0.0",

@@ -64,0 +69,0 @@ "restream": "3.5.0"

@@ -53,3 +53,3 @@ # @idio/frontend

logger: { use: true },
frontend: {
_frontend: {
use: true,

@@ -91,4 +91,9 @@ middlewareConstructor(_, config) {

import Component from './Component'
// linked node_modules are also resolved
import { Form, Input } from '@depack/form'
render(<Component test="Welcome"/>, document.body)
render(<Form>
<Input placeholder="hello world"/>
</Form>, document.body)
```

@@ -116,3 +121,3 @@

![Chrome Example](docs/Example.gif)
![Chrome Example](docs/Example1.gif)

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

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

import { collect } from 'catchment'
import { Replaceable } from 'restream'
import read from '@wrote/read'
import { relative, join, dirname } from 'path'
import transpileJSX from '@a-la/jsx'
import resolveDependency from 'resolve-dependency'
import exists from '@wrote/exists'
import { patchSource } from './lib'

@@ -27,5 +25,8 @@ /**

const p = ctx.path.replace('/', '')
if (p == directory || p.startsWith(`${directory}/`)) {
if ( p == directory
|| p.startsWith(`${directory}/`)
|| p.startsWith('node_modules/'))
{
const { path, isDir } = await resolveDependency(p)
if (isDir) {
if (isDir && !p.endsWith('/')) {
ctx.redirect(`/${path}`)

@@ -38,7 +39,2 @@ return

ctx.body = body
} else if (p.startsWith('node_modules/')) {
let body = await read(p)
body = await patch(p, body, pragma)
ctx.body = body
ctx.type = 'application/javascript'
} else {

@@ -80,54 +76,3 @@ await next()

const patchSource = async (path, source) => {
const replacement = async (m, pre, from) => {
if (/^[/.]/.test(from)) {
const dir = dirname(path)
const p = join(dir, from)
const { path: rd } = await resolveDependency(p)
const rel = relative(dir, rd)
const r = rel.startsWith('.') ? rel : `./${rel}`
return `${pre}'${r}'`
}
let [scope, name, ...paths] = from.split('/')
if (!scope.startsWith('@') && name) {
paths = [name, ...paths]
name = scope
} else {
name = `${scope}/${name}`
}
if (paths.length) {
return getNodeModule(name, paths.join('/'), pre)
}
const { module: mod } = require(`${from}/package.json`)
if (!mod) {
console.warn('[↛] Package %s does not specify module in package.json, trying src', from)
const d = getNodeModule(from, 'src', pre)
return d
}
return getNodeModule(from, mod, pre)
}
const rs = new Replaceable([
{
re: /^( *import(?:\s+[^\s,]+\s*,?)?(?:\s*{(?:[^}]+)})?\s+from\s+)['"](.+)['"]/gm,
replacement,
},
{
re: /^( *import\s+)['"](.+)['"]/gm,
replacement,
},
])
rs.end(source)
const body = await collect(rs)
return body
}
/**
* Returns the import statement with the path to the dependency on the file system.
*/
const getNodeModule = (from, path, pre) => {
const modPath = require.resolve(`${from}/${path}`)
const modRel = relative('', modPath)
return `${pre}'/${modRel}'`
}
/* documentary types/index.xml */

@@ -134,0 +79,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