@tabula/forge
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -5,3 +5,3 @@ // src/cli/run.ts | ||
// package.json | ||
var version = "0.2.0"; | ||
var version = "0.2.1"; | ||
@@ -172,2 +172,3 @@ // src/cli/createCommand.ts | ||
import { fromObject } from "convert-source-map"; | ||
import { readPackageUpSync } from "read-pkg-up"; | ||
async function renderCss({ path }) { | ||
@@ -181,2 +182,38 @@ const css = await readFile3(path, "utf8"); | ||
} | ||
function findImportDirectly(name, localRequire) { | ||
try { | ||
const path = localRequire.resolve(`${name}/package.json`); | ||
const dir = dirname(path); | ||
const json = localRequire(path); | ||
if (json.sass == null) { | ||
return null; | ||
} | ||
return join2(dir, json.sass); | ||
} catch { | ||
return null; | ||
} | ||
} | ||
function findImportConditionally(name, localRequire) { | ||
try { | ||
const entry = localRequire.resolve(name); | ||
const result = readPackageUpSync({ cwd: dirname(entry) }); | ||
if (result == null) { | ||
return null; | ||
} | ||
const { packageJson, path } = result; | ||
if (packageJson.sass == null) { | ||
return null; | ||
} | ||
return join2(dirname(path), packageJson.sass); | ||
} catch { | ||
return null; | ||
} | ||
} | ||
function findImport(name, localRequire) { | ||
const directImport = findImportDirectly(name, localRequire); | ||
if (directImport != null) { | ||
return directImport; | ||
} | ||
return findImportConditionally(name, localRequire); | ||
} | ||
function createImporter(path) { | ||
@@ -193,7 +230,4 @@ return { | ||
const localRequire = createRequire(path); | ||
const packageJsonPath = localRequire.resolve(`${url}/package.json`); | ||
const packageJsonDir = dirname(packageJsonPath); | ||
const packageJson = localRequire(packageJsonPath); | ||
if (packageJson.sass != null) { | ||
const importPath = join2(packageJsonDir, packageJson.sass); | ||
const importPath = findImport(url, localRequire); | ||
if (importPath != null) { | ||
return pathToFileURL(importPath); | ||
@@ -200,0 +234,0 @@ } |
{ | ||
"name": "@tabula/forge", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "The bundler for packages for Node.js and browser with support of various tools", | ||
@@ -5,0 +5,0 @@ "type": "module", |
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
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
79155
785