Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chialab/esbuild-plugin-meta-url

Package Overview
Dependencies
Maintainers
2
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chialab/esbuild-plugin-meta-url - npm Package Compare versions

Comparing version 0.18.0-alpha.0 to 0.18.0-alpha.1

22

lib/index.js
import path from 'path';
import { Buffer } from 'buffer';
import mime from 'mime-types';
import { appendSearchParam, getSearchParam, isUrl } from '@chialab/node-resolve';
import { getSearchParam, isUrl } from '@chialab/node-resolve';
import { parse, walk, getIdentifierValue, getBlock, getLocation, TokenType } from '@chialab/estransform';

@@ -180,14 +181,15 @@ import { useRna } from '@chialab/esbuild-rna';

const isIIFE = format === 'iife' && bundle;
const searchParams = new URLSearchParams();
let entryPoint;
let entryPoint = resolvedPath;
if (emit && !isIIFE) {
if (isChunk) {
const chunk = await build.emitChunk({ path: resolvedPath });
entryPoint = appendSearchParam(chunk.path, 'hash', chunk.id);
searchParams.set('hash', chunk.id);
entryPoint = chunk.path;
} else {
const file = await build.emitFile(resolvedPath);
entryPoint = appendSearchParam(file.path, 'hash', file.id);
searchParams.set('hash', file.id);
entryPoint = file.path;
}
} else {
entryPoint = path.relative(path.dirname(args.path), resolvedPath);
}

@@ -199,5 +201,5 @@

const { outputFiles } = await build.emitChunk({
path: `./${entryPoint}`,
path: `./${path.relative(workingDir, resolvedPath)}`,
write: false,
});
}, false);
if (outputFiles) {

@@ -227,3 +229,5 @@ mimeType = mime.lookup(outputFiles[0].path);

helpers.overwrite(startToken.start, endToken.end, `new URL('./${entryPoint.split(path.sep).join('/')}', ${baseUrl})`);
const outputPath = build.resolveRelativePath(entryPoint);
const searchParamsString = searchParams.toString();
helpers.overwrite(startToken.start, endToken.end, `new URL('${outputPath}${searchParamsString ? `?${searchParamsString}` : ''}', ${baseUrl})`);
return;

@@ -230,0 +234,0 @@ }

{
"name": "@chialab/esbuild-plugin-meta-url",
"type": "module",
"version": "0.18.0-alpha.0",
"version": "0.18.0-alpha.1",
"description": "A file loader plugin for esbuild for constructed URLs using import metadata.",

@@ -33,5 +33,5 @@ "main": "lib/index.js",

"dependencies": {
"@chialab/esbuild-rna": "^0.18.0-alpha.0",
"@chialab/estransform": "^0.18.0-alpha.0",
"@chialab/node-resolve": "^0.18.0-alpha.0",
"@chialab/esbuild-rna": "^0.18.0-alpha.1",
"@chialab/estransform": "^0.18.0-alpha.1",
"@chialab/node-resolve": "^0.18.0-alpha.1",
"mime-types": "^2.1.35"

@@ -41,5 +41,5 @@ },

"@types/mime-types": "^2.1.1",
"esbuild": "^0.17.0",
"typescript": "^4.3.0"
"esbuild": "^0.19.0",
"typescript": "^5.0.0"
}
}

@@ -28,6 +28,9 @@ <p align="center">

```sh
$ npm i @chialab/esbuild-plugin-meta-url -D
$ yarn add @chialab/esbuild-plugin-meta-url -D
npm i @chialab/esbuild-plugin-meta-url -D
```
```sh
yarn add @chialab/esbuild-plugin-meta-url -D
```
## Usage

@@ -34,0 +37,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc