Skip to content

Commit 36a89db

Browse files
committed
feat: add Yarn PnP support
1 parent 2ff541e commit 36a89db

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,26 @@ jobs:
4141
WITH_LOG: true
4242
LIGHTHOUSE_CHROMIUM_PATH: 'which google-chrome-stable'
4343
run: npm run test
44+
pnpTest:
45+
name: PnPTest
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v2
49+
with:
50+
fetch-depth: 1
51+
52+
- uses: actions/setup-node@v1
53+
with:
54+
node-version: 12.x
55+
56+
- name: Run PnP test
57+
run: |
58+
git clone https://github.com/preactjs-templates/default.git default
59+
cd default/template
60+
touch yarn.lock
61+
echo $(cat package.json | jq '.name = "pnp-test"') > package.json
62+
yarn set version 2
63+
yarn config set pnpFallbackMode none
64+
yarn config set compressionLevel 0
65+
yarn link -A -p ../..
66+
yarn build

packages/cli/lib/lib/webpack/webpack-base-config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const ReplacePlugin = require('webpack-plugin-replace');
1212
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
1313
const createBabelConfig = require('../babel-config');
1414
const loadPostcssConfig = require('postcss-load-config');
15+
const PnpWebpackPlugin = require(`pnp-webpack-plugin`);
1516

1617
function readJson(file) {
1718
try {
@@ -156,6 +157,10 @@ module.exports = function (env) {
156157
? require.resolve('@preact/async-loader/async')
157158
: require.resolve('@preact/async-loader/async-legacy'),
158159
},
160+
plugins: [
161+
// TODO: Remove when upgrading to webpack 5
162+
PnpWebpackPlugin,
163+
],
159164
},
160165

161166
module: {

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"native-url": "0.3.4",
128128
"optimize-css-assets-webpack-plugin": "^5.0.1",
129129
"ora": "^4.0.3",
130+
"pnp-webpack-plugin": "^1.6.4",
130131
"postcss-load-config": "^2.1.0",
131132
"postcss-loader": "^3.0.0",
132133
"progress-bar-webpack-plugin": "^2.1.0",

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11187,6 +11187,13 @@ pn@^1.1.0:
1118711187
resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
1118811188
integrity sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==
1118911189

11190+
pnp-webpack-plugin@^1.6.4:
11191+
version "1.6.4"
11192+
resolved "https://registry.yarnpkg.com/pnp-webpack-plugin/-/pnp-webpack-plugin-1.6.4.tgz#c9711ac4dc48a685dabafc86f8b6dd9f8df84149"
11193+
integrity sha512-7Wjy+9E3WwLOEL30D+m8TSTF7qJJUJLONBnwQp0518siuMxUQUbgZwssaFX+QKlZkjHZcw/IpZCt/H0srrntSg==
11194+
dependencies:
11195+
ts-pnp "^1.1.6"
11196+
1119011197
polka@^0.5.2:
1119111198
version "0.5.2"
1119211199
resolved "https://registry.yarnpkg.com/polka/-/polka-0.5.2.tgz#588bee0c5806dbc6c64958de3a1251860e9f2e26"
@@ -14047,6 +14054,11 @@ tryer@^1.0.1:
1404714054
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
1404814055
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==
1404914056

14057+
ts-pnp@^1.1.6:
14058+
version "1.2.0"
14059+
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
14060+
integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw==
14061+
1405014062
tslib@^1.9.0:
1405114063
version "1.13.0"
1405214064
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"

0 commit comments

Comments
 (0)