Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sheetify

Package Overview
Dependencies
Maintainers
3
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sheetify - npm Package Compare versions

Comparing version 4.0.2 to 4.0.3

lib/css-resolve.js

2

package.json
{
"name": "sheetify",
"version": "4.0.2",
"version": "4.0.3",
"description": "Modular CSS bundler",

@@ -5,0 +5,0 @@ "repository": "sheetify/sheetify",

@@ -193,2 +193,10 @@ # sheetify

## FAQ
### Help, why isn't my inline CSS being transformed?
Well, that might be because you're running `babelify` before running
`sheetify`. `sheetify` looks for template strings in your code and then
transforms them as inline stylesheets. If these are caught and transformed to
ES5 strings by `babelify` then `sheetify` ends up sad. So try running
`sheetify` before `babelify` and you should be good, we hope.
## Installation

@@ -199,2 +207,11 @@ ```sh

## See Also
- [browserify](https://github.com/substack/node-browserify) - browser-side
require() the node.js way
- [glslify](https://github.com/stackgl/glslify) - module system for GLSL
shaders
- [hyperx](https://github.com/substack/hyperx) - transform inline HTML to JS
- [bankai](https://github.com/yoshuawuyts/bankai) - DIY server middleware for
JS, CSS and HTML
## License

@@ -201,0 +218,0 @@ [MIT](https://tldrlegal.com/license/mit-license)

@@ -8,4 +8,2 @@ const browserify = require('browserify')

const sheetify = require(path.join(__dirname, '../transform'))
const expath = require.resolve('css-type-base/index.css')
const expected = fs.readFileSync(expath, 'utf8').trim()

@@ -15,2 +13,5 @@ test('import', function (t) {

const expath = require.resolve('css-type-base/index.css')
const expected = fs.readFileSync(expath, 'utf8').trim()
const ws = concat(function (buf) {

@@ -34,1 +35,28 @@ const res = String(buf).trim()

})
test('broken import should emit an error', function (t) {
t.plan(1)
const inpath = path.join(__dirname, 'import/broken.js')
const ws = concat(function (buf) {
const res = String(buf).trim()
console.log(res)
})
const bOpts = { browserField: false }
const b = browserify(inpath, bOpts)
b.transform(sheetify, {
basedir: path.join(__dirname, 'plugins'),
o: ws
})
const r = b.bundle()
r.resume()
r.on('error', function (e) {
t.ok(/cannot be imported/.test(e), 'emits an error')
})
r.on('end', function () {
ws.end()
})
})

@@ -6,3 +6,2 @@ const mapLimit = require('map-limit')

const falafel = require('falafel')
const resolve = require('resolve')
const assert = require('assert')

@@ -14,2 +13,3 @@ const mkdirp = require('mkdirp')

const cssResolve = require('./lib/css-resolve')
const sheetify = require('./index')

@@ -150,18 +150,23 @@

else transformStream.emit('file', fnp)
const fnCss = fs.readFileSync(fnp, 'utf8').trim()
try {
const fnCss = fs.readFileSync(fnp, 'utf8').trim()
// read optional arguments passed in to node
// e.g. { global: false }
if (node.arguments[1] && node.arguments[1].properties) {
const props = node.arguments[1].properties
props.forEach(function (prop) {
opts[prop.key.name] = prop.value.value
// read optional arguments passed in to node
// e.g. { global: false }
if (node.arguments[1] && node.arguments[1].properties) {
const props = node.arguments[1].properties
props.forEach(function (prop) {
opts[prop.key.name] = prop.value.value
})
}
sheetify(fnCss, fnp, opts, function (tf) {
nodes.push([ tf, node ])
})
return
} catch (e) {
const errMsg = 'sheetify: ' + e.path + ' cannot be imported'
return transformStream.emit('error', errMsg)
}
sheetify(fnCss, fnp, opts, function (tf) {
nodes.push([ tf, node ])
})
return
}

@@ -173,26 +178,1 @@ }

function expr (ex) { return { _expr: ex.source() } }
// find a file in CSS with either a {style} field
// or main with `.css` in it
// (str, str) -> str
function cssResolve (pkgname, basedir) {
try {
const res = resolve.sync(pkgname, {
basedir: pkgname,
packageFilter: packageFilter
})
if (path.extname(res) !== '.css') {
throw new Error('path ' + res + ' is not a CSS file')
}
return res
} catch (e) {
return
}
function packageFilter (pkg, path) {
if (pkg.style) pkg.main = pkg.style
return pkg
}
}
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