Skip to content

Commit

Permalink
refactor: update esbuild and remove esbuild-plugin-pnp (#4732)
Browse files Browse the repository at this point in the history
* refactor: Deprecate esbuild-plugin-pnp

* Update e2e workflow

* Update .yarn/versions/ded9c7c0.yml

Co-authored-by: Kristoffer K. <merceyz@users.noreply.github.com>

* deps: `esbuild-wasm@0.15.3`

* deps: `esbuild-wasm@0.15.5`

* chore: remove `baseUrl`

* Fixes use strict

* Restores the readme to explain the deprecation

Co-authored-by: Kristoffer K. <merceyz@users.noreply.github.com>
Co-authored-by: Maël Nison <nison.mael@gmail.com>
  • Loading branch information
3 people authored Sep 2, 2022
1 parent a66e528 commit 4c8ab43
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 335 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/e2e-esbuild-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
source scripts/e2e-setup-ci.sh
yarn init -p
yarn add -D esbuild @yarnpkg/esbuild-plugin-pnp@portal:"$HERE_DIR/../packages/esbuild-plugin-pnp" ts-node typescript
yarn add -D esbuild ts-node typescript
echo "require('esbuild').build({bundle: true, format: 'cjs', target: 'node14', entryPoints: ['./src/main.js'], outfile: './dist/bundle.js', plugins: [require('@yarnpkg/esbuild-plugin-pnp').pnpPlugin()]})" > build.js
echo "require('esbuild').build({bundle: true, format: 'cjs', target: 'node14', entryPoints: ['./src/main.js'], outfile: './dist/bundle.js'})" > build.js
# Tree-shaking
echo "export default {input: 'src/main.js', output: {file: 'dist/bundle.js', format: 'cjs'}};" | tee rollup.config.js
Expand All @@ -50,7 +50,7 @@ jobs:
[[ "$(node dist/bundle.js)" = "Hello webpack" ]]
# Make sure we play nicely with esbuild plugins that create virtual modules with resolveDirs
echo "require('esbuild').build({bundle: true, format: 'cjs', target: 'node14', entryPoints: ['./src/main.js'], outfile: './dist/bundle.js', plugins: [require('./virtualModulePlugin'), require('@yarnpkg/esbuild-plugin-pnp').pnpPlugin()]})" > build.js
echo "require('esbuild').build({bundle: true, format: 'cjs', target: 'node14', entryPoints: ['./src/main.js'], outfile: './dist/bundle.js', plugins: [require('./virtualModulePlugin')]})" > build.js
cat <<- "EOF" | tee virtualModulePlugin.js
const { resolve, dirname } = require('path');
module.exports = {
Expand All @@ -70,4 +70,4 @@ jobs:
echo "import {virtual} from './maths.js?virtual'; console.log(virtual.cube(6));" | tee src/main.js
yarn ts-node --transpile-only build.js
[[ "$(node dist/bundle.js)" = "216" ]]
[[ "$(node dist/bundle.js)" = "216" ]]
55 changes: 8 additions & 47 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
36 changes: 36 additions & 0 deletions .yarn/versions/ded9c7c0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
releases:
"@yarnpkg/builder": patch
"@yarnpkg/core": patch
"@yarnpkg/plugin-pnp": patch
"@yarnpkg/pnp": patch
vscode-zipfs: patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/cli"
- "@yarnpkg/doctor"
- "@yarnpkg/extensions"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
23 changes: 3 additions & 20 deletions packages/esbuild-plugin-pnp/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
# `@yarnpkg/esbuild-plugin-pnp`
# esbuild-plugin-pnp

This plugin lets you use Yarn with esbuild. We use it in order to build Yarn itself!
Yarn used to maintain a plugin called [`esbuild-plugin-pnp`](https://yarnpkg.com/package/@yarnpkg/esbuild-plugin-pnp) which added PnP support to Esbuild.

## Usage

Add the plugin to your dependencies:

```
yarn add @yarnpkg/esbuild-plugin-pnp
```

Reference it via your esbuild configuration ([build API only](https://esbuild.github.io/plugins/)):

```ts
import {pnpPlugin} from '@yarnpkg/esbuild-plugin-pnp';

await build({
plugins: [pnpPlugin()],
// ...
});
```
Starting from Esbuild 0.15, this plugin isn't needed anymore and has been deprecated: [Esbuild now implements native support](https://esbuild.github.io/getting-started/#yarn-pnp) for both PnP and zip archives, with much better performances than what the plugin could achieve.
37 changes: 0 additions & 37 deletions packages/esbuild-plugin-pnp/package.json

This file was deleted.

Loading

0 comments on commit 4c8ab43

Please sign in to comment.