Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update esbuild and remove esbuild-plugin-pnp #4732

Merged
merged 9 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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