Skip to content

Commit

Permalink
improved esbuild plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed May 2, 2024
1 parent ab1f066 commit bdd1ad1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
### Added
- Feed plugin: Add image support [#599], [#598].
- New middleware `shutdown`.
- Esbuild plugin: support for `jsr:` specifiers.

### Changed
- For better predictability, the `_cache` folder is generated in the root folder, instead of `src` folder.
Expand All @@ -18,7 +19,8 @@ Go to the `v1` branch to see the changelog of Lume 1.

### Fixed
- Updated dependencies: `unocss`, `liquid`, `postcss-nesting`, `terser`, `xml`, `react`, `std`, `sass`, `preact`.
- FFF plugin: fix `getGitDate` priority. [#603]
- FFF plugin: fix `getGitDate` priority [#603].
- Esbuild plugin: resolve bare specifiers mapped to `npm:`.

## [2.1.4] - 2024-04-17
### Added
Expand Down
16 changes: 8 additions & 8 deletions plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,21 @@ export default function (userOptions?: Options) {
site.loadAssets(options.extensions);

function resolve(path: string) {
// "npm:" specifiers are currently not supported in import.meta.resolve()
// https://github.com/denoland/deno/issues/21298
if (!path.startsWith("npm:")) {
path = import.meta.resolve(path);
}
path = import.meta.resolve(path);
const match = path.match(/^(npm|jsr):(.*)$/);

if (!path.startsWith("npm:")) {
if (!match) {
return {
path,
namespace: "deno",
};
}

const name = path.replace(/^npm:/, "");
const url = new URL(`https://esm.sh/${name}`);
const [, prefix, name] = match;

const url = prefix === "npm"
? new URL(`https://esm.sh/${name}`)
: new URL(`https://esm.sh/jsr/${name}`);

if (options.esm.dev) {
url.searchParams.set("dev", "true");
Expand Down

0 comments on commit bdd1ad1

Please sign in to comment.