@bookshop/builder
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
{"processes":{"20be900c-e499-4599-9746-17201f13c62c":{"parent":"36ff515c-0dfc-47cf-9497-b412f7de3421","children":[]},"36ff515c-0dfc-47cf-9497-b412f7de3421":{"parent":null,"children":["20be900c-e499-4599-9746-17201f13c62c","6c6589a1-cad7-4728-87c0-5adfacb21d80","8bbe02a3-2b50-40c8-9824-2bbb04c0ce87","af3d3c73-82f8-4297-aeb6-686cb9cf895d","e6c95401-f868-452e-97f1-59d27c3b94de"]},"6c6589a1-cad7-4728-87c0-5adfacb21d80":{"parent":"36ff515c-0dfc-47cf-9497-b412f7de3421","children":[]},"8bbe02a3-2b50-40c8-9824-2bbb04c0ce87":{"parent":"36ff515c-0dfc-47cf-9497-b412f7de3421","children":[]},"af3d3c73-82f8-4297-aeb6-686cb9cf895d":{"parent":"36ff515c-0dfc-47cf-9497-b412f7de3421","children":[]},"e6c95401-f868-452e-97f1-59d27c3b94de":{"parent":"36ff515c-0dfc-47cf-9497-b412f7de3421","children":[]}},"files":{},"externalIds":{}} | ||
{"processes":{"58684f35-8208-4ecc-9e90-fe6fa98253c1":{"parent":"9ae73bc4-effc-4b6c-b9e0-92f9d25efd8c","children":[]},"7679c1f9-25f5-40ac-8198-b46661572eef":{"parent":"9ae73bc4-effc-4b6c-b9e0-92f9d25efd8c","children":[]},"7c3846ad-56ea-4d75-92fd-cab4ad02f4fa":{"parent":"9ae73bc4-effc-4b6c-b9e0-92f9d25efd8c","children":[]},"9ae73bc4-effc-4b6c-b9e0-92f9d25efd8c":{"parent":null,"children":["58684f35-8208-4ecc-9e90-fe6fa98253c1","7679c1f9-25f5-40ac-8198-b46661572eef","7c3846ad-56ea-4d75-92fd-cab4ad02f4fa","bdac43f3-685c-4265-8b07-15a02b2ea81d","cd3b0605-6069-4f9f-91a6-8c24e074c858"]},"bdac43f3-685c-4265-8b07-15a02b2ea81d":{"parent":"9ae73bc4-effc-4b6c-b9e0-92f9d25efd8c","children":[]},"cd3b0605-6069-4f9f-91a6-8c24e074c858":{"parent":"9ae73bc4-effc-4b6c-b9e0-92f9d25efd8c","children":[]}},"files":{},"externalIds":{}} |
@@ -13,3 +13,3 @@ import path from 'path'; | ||
build.onLoad({ filter: /.*/, namespace: 'bookshop-import-components' }, async (args) => { | ||
const fileContents = `import components from '__bookshop_glob__(.bookshop.toml)';export default components;`; | ||
const fileContents = `import components from '__bookshop_glob__(.bookshop.*)';export default components;`; | ||
return { contents: fileContents }; | ||
@@ -16,0 +16,0 @@ }); |
import test from 'ava'; | ||
import path from 'path'; | ||
import {stubExternalPlugin} from '../../.test/common.js'; | ||
import { stubExternalPlugin } from '../../.test/common.js'; | ||
import bookshopComponentPlugin from './bookshopComponentPlugin.js'; | ||
@@ -29,7 +29,7 @@ import esbuild from 'esbuild'; | ||
}); | ||
t.is(result.errors.length, 0); | ||
t.is(result.warnings.length, 0); | ||
let m = /import components from "__bookshop_glob__\(.bookshop.toml\)";/; | ||
let m = /import components from "__bookshop_glob__\(.bookshop.*\)";/; | ||
t.regex(result.outputFiles[0].text, m); | ||
}); |
import path from 'path'; | ||
import url from 'url'; | ||
import normalizePath from 'normalize-path'; | ||
import resolve from 'resolve'; | ||
@@ -26,4 +27,15 @@ const importEngineConfig = async ([engine, data]) => { | ||
data.plugins = data.plugins || []; | ||
let engineImportPath = engine; | ||
if (process.platform !== "win32") { | ||
// TODO: It looks like resolve is mangling this path on Windows | ||
// This is a pretty obscure fix and is more likely to affect CI, | ||
// so opting Windows out of this for now. | ||
try { | ||
// Try to force loading the engine from cwd if we can resolve it | ||
engineImportPath = resolve.sync(engine, { basedir: process.cwd() }); | ||
} catch (e) { } | ||
} | ||
return ` | ||
import {Engine as ${engineKey}} from '${engine}'; | ||
import {Engine as ${engineKey}} from '${engineImportPath}'; | ||
import ${engineKey}Files from "__bookshop_glob__${joinExtensions(__engine.extensions)}"; | ||
@@ -68,3 +80,3 @@ | ||
build.onLoad({ filter: /.*/, namespace: 'bookshop-import-config' }, async (args) => { | ||
const {default: config} = await import(url.pathToFileURL(path.join(args.pluginData.resolveDir, args.path))); | ||
const { default: config } = await import(url.pathToFileURL(path.join(args.pluginData.resolveDir, args.path))); | ||
let engines = Object.entries(config?.engines) || []; | ||
@@ -71,0 +83,0 @@ if (options?.onlyEngines?.length) { |
import test from 'ava'; | ||
import path from 'path'; | ||
import {stubExternalPlugin} from '../../.test/common.js'; | ||
import { stubExternalPlugin } from '../../.test/common.js'; | ||
import bookshopConfigPlugin from './bookshopConfigPlugin.js'; | ||
@@ -24,3 +24,3 @@ import esbuild from 'esbuild'; | ||
stubExternalPlugin("skip-bookshop-globs", /^__bookshop_glob__/), | ||
stubExternalPlugin("skip-bookshop-globs", /^@bookshop/) | ||
stubExternalPlugin("skip-bookshop-globs", /@bookshop/) | ||
], | ||
@@ -31,6 +31,6 @@ format: 'esm', | ||
}); | ||
t.is(result.errors.length, 0); | ||
t.is(result.warnings.length, 0); | ||
t.regex(result.outputFiles[0].text, /import {\s*Engine as Engine0\s*} from "@bookshop\/jekyll-engine";/); | ||
t.regex(result.outputFiles[0].text, /import {\s*Engine as Engine0\s*} from ".*@bookshop\/jekyll-engine.*";/); | ||
t.regex(result.outputFiles[0].text, /import Engine0Files from "__bookshop_glob__\(.jekyll.html\)";/); | ||
@@ -58,3 +58,3 @@ }); | ||
}); | ||
t.is(result.errors.length, 0); | ||
@@ -61,0 +61,0 @@ t.is(result.warnings.length, 0); |
import path from 'path'; | ||
import fs from 'fs'; | ||
import { createRequire } from 'module'; | ||
import { filterBookshops, loadConfig } from './lib/bookshopHelper.js'; | ||
@@ -11,2 +12,5 @@ import bookshopComponentPlugin from './lib/plugins/bookshopComponentPlugin.js'; | ||
const require = createRequire(import.meta.url); | ||
const { version } = require('./package.json'); | ||
export default async (options) => { | ||
@@ -22,6 +26,11 @@ options = { | ||
loader: {}, | ||
define: {}, | ||
...(options.esbuild || {}) | ||
} | ||
esbuildOptions.loader[".bookshop.toml"] = "text"; | ||
esbuildOptions.loader[".bookshop.yml"] = "text"; | ||
esbuildOptions.loader[".bookshop.json"] = "text"; | ||
esbuildOptions.define["BOOKSHOP_VERSION"] = JSON.stringify(version); | ||
options.bookshopDirs = filterBookshops(options.bookshopDirs); | ||
@@ -28,0 +37,0 @@ options.bookshopConfig = await loadConfig(options.bookshopDirs[0]); |
{ | ||
"name": "@bookshop/builder", | ||
"packageManager": "yarn@3.0.0", | ||
"version": "2.6.1", | ||
"version": "3.0.0-beta.0", | ||
"description": "esbuild wrapper for bringing bookshop components and engines throught to a frontend", | ||
@@ -22,3 +22,3 @@ "type": "module", | ||
"devDependencies": { | ||
"@bookshop/jekyll-engine": "2.6.1", | ||
"@bookshop/jekyll-engine": "3.0.0-beta.0", | ||
"ava": "^3.15.0", | ||
@@ -28,7 +28,8 @@ "nyc": "^15.1.0" | ||
"dependencies": { | ||
"@bookshop/helpers": "2.6.1", | ||
"@bookshop/styles": "2.6.1", | ||
"@bookshop/helpers": "3.0.0-beta.0", | ||
"@bookshop/styles": "3.0.0-beta.0", | ||
"esbuild": "^0.13.10", | ||
"fast-glob": "^3.2.7", | ||
"normalize-path": "^3.0.0" | ||
"normalize-path": "^3.0.0", | ||
"resolve": "^1.22.0" | ||
}, | ||
@@ -35,0 +36,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
33438
2.83%686
2.69%6
20%2
100%6
20%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed