rollup-plugin-filesize
Advanced tools
Comparing version 8.0.1 to 8.0.2
@@ -34,4 +34,14 @@ 'use strict'; | ||
const readFile = util.promisify(fs.readFile); | ||
const thisDirectory = path.dirname(new URL((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href))).pathname); | ||
const isWindows = process.platform === "win32"; | ||
function fixWindowsPath(path) { | ||
return path.slice( // istanbul ignore next | ||
isWindows ? 1 : 0); | ||
} // Node should be ok with this, but transpiling | ||
// to `require` doesn't work, so detect Windows | ||
// to remove slash instead | ||
// "file://" + | ||
const thisDirectory = fixWindowsPath(path.dirname(new URL((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href))).pathname)); | ||
function filesize(options = {}, env) { | ||
@@ -62,3 +72,3 @@ let { | ||
name | ||
} = await new Promise(function (resolve) { resolve(_interopNamespace(require(path.join(process.cwd(), "./package.json")))); }); | ||
} = await new Promise(function (resolve) { resolve(_interopNamespace(require(fixWindowsPath(path.join(process.cwd(), "./package.json"))))); }); | ||
@@ -130,15 +140,5 @@ try { | ||
if (reporter === "boxen") { | ||
p = new Promise(function (resolve) { resolve(_interopNamespace(require( // Node should be ok with this, but transpiling | ||
// to `require` doesn't work, so detect Windows | ||
// to remove slash instead | ||
// "file://" + | ||
path.dirname(new URL((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href))).pathname).slice( // istanbul ignore next | ||
isWindows ? 1 : 0) + "/reporters/boxen.js"))); }); | ||
p = new Promise(function (resolve) { resolve(_interopNamespace(require(thisDirectory + "/reporters/boxen.js"))); }); | ||
} else { | ||
p = new Promise(function (resolve) { resolve(_interopNamespace(require( // Node should be ok with this, but transpiling | ||
// to `require` doesn't work, so detect Windows | ||
// to remove slash instead | ||
// "file://" + | ||
path.resolve(process.cwd(), reporter).slice( // istanbul ignore next | ||
isWindows ? 1 : 0)))); }); | ||
p = new Promise(function (resolve) { resolve(_interopNamespace(require(fixWindowsPath(path.resolve(process.cwd(), reporter))))); }); | ||
} | ||
@@ -145,0 +145,0 @@ |
{ | ||
"name": "rollup-plugin-filesize", | ||
"version": "8.0.1", | ||
"version": "8.0.2", | ||
"description": "A rollup plugin to show filesize in the cli", | ||
@@ -10,3 +10,5 @@ "main": "dist/index.js", | ||
"dist", | ||
"README" | ||
"README", | ||
"!.DS_Store", | ||
"!.nyc_output" | ||
], | ||
@@ -13,0 +15,0 @@ "scripts": { |
@@ -13,6 +13,19 @@ import { readFile as origReadFile } from "fs"; | ||
const thisDirectory = dirname(new URL(import.meta.url).pathname); | ||
const isWindows = process.platform === "win32"; | ||
function fixWindowsPath(path) { | ||
return path.slice( | ||
// istanbul ignore next | ||
isWindows ? 1 : 0 | ||
); | ||
} | ||
// Node should be ok with this, but transpiling | ||
// to `require` doesn't work, so detect Windows | ||
// to remove slash instead | ||
// "file://" + | ||
const thisDirectory = fixWindowsPath( | ||
dirname(new URL(import.meta.url).pathname) | ||
); | ||
export default function filesize(options = {}, env) { | ||
@@ -37,3 +50,5 @@ let { | ||
if (showBeforeSizes !== "build") { | ||
const { name } = await import(join(process.cwd(), "./package.json")); | ||
const { name } = await import( | ||
fixWindowsPath(join(process.cwd(), "./package.json")) | ||
); | ||
try { | ||
@@ -129,23 +144,5 @@ const output = join(thisDirectory, "../.cache"); | ||
if (reporter === "boxen") { | ||
p = import( | ||
// Node should be ok with this, but transpiling | ||
// to `require` doesn't work, so detect Windows | ||
// to remove slash instead | ||
// "file://" + | ||
dirname(new URL(import.meta.url).pathname).slice( | ||
// istanbul ignore next | ||
isWindows ? 1 : 0 | ||
) + "/reporters/boxen.js" | ||
); | ||
p = import(thisDirectory + "/reporters/boxen.js"); | ||
} else { | ||
p = import( | ||
// Node should be ok with this, but transpiling | ||
// to `require` doesn't work, so detect Windows | ||
// to remove slash instead | ||
// "file://" + | ||
pathResolve(process.cwd(), reporter).slice( | ||
// istanbul ignore next | ||
isWindows ? 1 : 0 | ||
) | ||
); | ||
p = import(fixWindowsPath(pathResolve(process.cwd(), reporter))); | ||
} | ||
@@ -152,0 +149,0 @@ reporter = (await p).default; |
Sorry, the diff of this file is not supported yet
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
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
32966
385
6