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.16.1 to 0.16.2

24

lib/index.js
import path from 'path';
import { appendSearchParam, getSearchParam, isUrl } from '@chialab/node-resolve';
import { parse, walk, getIdentifierValue, getBlock, getLocation, TokenType } from '@chialab/estransform';
import { useRna } from '@chialab/esbuild-rna';
import { Build, useRna } from '@chialab/esbuild-rna';

@@ -111,5 +111,5 @@ /**

name: 'meta-url',
async setup(build) {
const { platform, format, sourcesContent, sourcemap } = build.initialOptions;
const { onTransform, isEmittedPath, resolveLocallyFirst, emitFile, emitChunk, loaders: buildLoaders } = useRna(build);
async setup(pluginBuild) {
const build = useRna(pluginBuild);
const { platform, format, sourcesContent, sourcemap } = build.getOptions();

@@ -130,3 +130,3 @@ const usePlainScript = platform === 'browser' && format !== 'esm';

onTransform({ loaders: ['tsx', 'ts', 'jsx', 'js'] }, async (args) => {
build.onTransform({ loaders: ['tsx', 'ts', 'jsx', 'js'] }, async (args) => {
const code = args.code;

@@ -158,3 +158,3 @@

const id = getSearchParam(value, 'hash');
if (id && isEmittedPath(id)) {
if (id && build.isEmittedPath(id)) {
return;

@@ -169,3 +169,3 @@ }

const requestName = value.split('?')[0];
const { path: resolvedPath, pluginData: localFile } = await resolveLocallyFirst(requestName, {
const { path: resolvedPath, pluginData } = await build.resolveLocallyFirst(requestName, {
kind: 'dynamic-import',

@@ -179,5 +179,6 @@ importer: args.path,

if (resolvedPath) {
if (!localFile) {
if (pluginData !== Build.RESOLVED_AS_FILE) {
const location = getLocation(code, startToken.start);
warnings.push({
id: 'import-meta-module-resolution',
pluginName: 'meta-url',

@@ -198,3 +199,3 @@ text: `Resolving '${requestName}' as module is not a standard behavior and may be removed in a future relase of the plugin.`,

const entryLoader = buildLoaders[path.extname(resolvedPath)] || 'file';
const entryLoader = build.getLoader(resolvedPath) || 'file';
const isChunk = entryLoader !== 'file' && entryLoader !== 'json';

@@ -204,6 +205,6 @@ let entryPoint;

if (isChunk) {
const chunk = await emitChunk({ path: resolvedPath });
const chunk = await build.emitChunk({ path: resolvedPath });
entryPoint = appendSearchParam(chunk.path, 'hash', chunk.id);
} else {
const file = await emitFile(resolvedPath);
const file = await build.emitFile(resolvedPath);
entryPoint = appendSearchParam(file.path, 'hash', file.id);

@@ -222,2 +223,3 @@ }

warnings.push({
id: 'import-meta-reference-not-found',
pluginName: 'meta-url',

@@ -224,0 +226,0 @@ text: `Unable to resolve '${requestName}' file.`,

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

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

"dependencies": {
"@chialab/esbuild-rna": "^0.16.1",
"@chialab/esbuild-rna": "^0.16.2",
"@chialab/estransform": "^0.16.0",

@@ -36,0 +36,0 @@ "@chialab/node-resolve": "^0.16.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