tailwind-scrollbar
Advanced tools
Comparing version 3.0.2 to 3.0.3
{ | ||
"name": "tailwind-scrollbar", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Tailwind plugin for styling scrollbars", | ||
@@ -5,0 +5,0 @@ "author": "Graham Still <graham@gstill.dev>", |
/** | ||
* Imports a default export agnostic of whether CommonJS is in use or not. | ||
* Gets the underlying default import of a module. | ||
* | ||
@@ -7,9 +7,9 @@ * This is used to handle internal imoprts from Tailwind, since Tailwind Play | ||
* | ||
* This is a hacky fix to get this working; in particular, it makes the typing | ||
* very loose. Converting the entire module to typescript might have the side | ||
* effect of making this function unnecessary. | ||
* | ||
* @param {string} path The path to import | ||
* @returns {unknown} The imported module | ||
* @template T | ||
* @param {T | { __esModule: unknown, default: T }} mod The module | ||
* @returns {T} The bare export | ||
*/ | ||
export function agnosticRequire(path: string): unknown; | ||
export function importDefault<T>(mod: T | { | ||
__esModule: unknown; | ||
default: T; | ||
}): T; |
/** | ||
* Imports a default export agnostic of whether CommonJS is in use or not. | ||
* Gets the underlying default import of a module. | ||
* | ||
@@ -7,18 +7,11 @@ * This is used to handle internal imoprts from Tailwind, since Tailwind Play | ||
* | ||
* This is a hacky fix to get this working; in particular, it makes the typing | ||
* very loose. Converting the entire module to typescript might have the side | ||
* effect of making this function unnecessary. | ||
* | ||
* @param {string} path The path to import | ||
* @returns {unknown} The imported module | ||
* @template T | ||
* @param {T | { __esModule: unknown, default: T }} mod The module | ||
* @returns {T} The bare export | ||
*/ | ||
const agnosticRequire = path => { | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
const exported = require(path); | ||
// eslint-disable-next-line no-underscore-dangle | ||
return exported.__esModule && exported.default ? exported.default : exported; | ||
}; | ||
// eslint-disable-next-line no-underscore-dangle | ||
const importDefault = mod => (mod?.__esModule ? mod.default : mod); | ||
module.exports = { | ||
agnosticRequire | ||
importDefault | ||
}; |
@@ -0,6 +1,10 @@ | ||
const flattenColorPaletteImport = require('tailwindcss/lib/util/flattenColorPalette'); | ||
const toColorValueImport = require('tailwindcss/lib/util/toColorValue'); | ||
const typedefs = require('./typedefs'); | ||
const { agnosticRequire } = require('./helpers'); | ||
const { importDefault } = require('./helpers'); | ||
const flattenColorPalette = agnosticRequire('tailwindcss/lib/util/flattenColorPalette'); | ||
const toColorValue = agnosticRequire('tailwindcss/lib/util/toColorValue'); | ||
// Tailwind Play will import these internal imports as ES6 imports, while most | ||
// other workflows will import them as CommonJS imports. | ||
const flattenColorPalette = importDefault(flattenColorPaletteImport); | ||
const toColorValue = importDefault(toColorValueImport); | ||
@@ -7,0 +11,0 @@ const COMPONENTS = ['track', 'thumb', 'corner']; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1
18686
376