GithubHelp home page GithubHelp logo

esbuild-plugin-raw's Introduction

esbuild-plugin-raw

Install

$ npm install -D esbuild-plugin-raw

Usage

With build script

import esbuild from 'esbuild'
import RawPlugin from 'esbuild-plugin-raw'

esbuild.build({
  entryPoints: ['app.js'],
  bundle: true,
  outfile: 'out.js',
  plugins: [RawPlugin],
}).catch(() => process.exit(1))

With tsup

import { defineConfig } from 'tsup'
import RawPlugin from 'esbuild-plugin-raw'

export default defineConfig({
  entryPoints: ['index.ts'],
  format: ['cjs', 'esm'],
  dts: true,
  esbuildPlugins: [RawPlugin()],
  clean: true,
})

License

MIT License © 2021 hannoeru

esbuild-plugin-raw's People

Contributors

filipsobol avatar hannoeru avatar mistic100 avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

esbuild-plugin-raw's Issues

Outputs full source file path

Describe the bug

I am using this plugin to load SVG files into my lib.

When I look at the generated files I can see comments like :

// raw-loader:B:\Projects\misc\esbuild-raw\icon.svg?raw

=> the plugin is outputing the full file path into the generated files. Beside being not very clean, I think it could lead to information leak (something something about system structure on a corporate computer).

I tried to replace this line

path: path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path),

by path: args.path and it seems to continue working without any issue and now the comment is simply

// raw-loader:./icon.svg?raw

I guess the path resolution is here to handle more complex cases, perhaps it could be done only in onLoad

Reproduction

https://github.com/mistic100/temp-esbuild-raw

System Info

Windows 10

Used Package Manager

yarn

Validations

  • Follow the Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A please open a GitHub Discussion.
  • The provided reproduction is a minimal reproducible example of the bug.

Please release new npm version

Description

0.1.7 doesn't list latest esbuilds as peer deps

Suggested solution

release 0.1.8 :)

Alternative

No response

Additional context

No response

Validations

  • Follow the Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yaml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
example/package.json
  • typescript ^5.4.5
package.json
  • @hannoeru/eslint-config ^0.9.7
  • @types/node ^20.12.7
  • esbuild ^0.20.2
  • eslint ^9.0.0
  • tsup ^8.0.2
  • typescript ^5.4.5
  • esbuild ^0.14.36 || ^0.15.0 || ^0.16.0 || ^0.17.0 || ^0.18.0 || ^0.19.0 || ^0.20.0
nvm
.nvmrc
  • node 20.12.2

  • Check this box to trigger a request for Renovate to run again on this repository

Usage guide

I'm trying to import .tsx content as raw text. There's no usage guide, so I'm not sure if this repo might be the answer. Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.