Skip to content

Commit 655707d

Browse files
committed
Fixes the punycode deprecation warning
1 parent 1c6b097 commit 655707d

File tree

1 file changed

+11
-50
lines changed

1 file changed

+11
-50
lines changed

scripts/build-webpack.js

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,20 @@ const fs = require('fs');
99

1010
// Otherwise Webpack 4 will be "helpful" and automatically mark the `punycode` package as external,
1111
// despite us wanting to bundle it since it will be removed from future Node.js versions.
12-
delete process.binding("natives").punycode;
12+
const binding = process.binding;
13+
process.binding = name => {
14+
let ret = binding(name);
1315

14-
const version = require('../package.json').version;
15-
const basedir = path.join(__dirname, '../');
16-
const babelRc = JSON.parse(fs.readFileSync(path.join(basedir, '.babelrc'), 'utf8'));
17-
18-
var PnpResolver = {
19-
apply: function(resolver) {
20-
resolver.plugin('resolve', function(request, callback) {
21-
if (request.context.issuer === undefined) {
22-
return callback();
23-
}
24-
25-
let basedir;
26-
let resolved;
27-
28-
if (!request.context.issuer) {
29-
basedir = request.path;
30-
} else if (request.context.issuer.startsWith('/')) {
31-
basedir = path.dirname(request.context.issuer);
32-
} else {
33-
throw 42;
34-
}
35-
36-
try {
37-
resolved = resolve.sync(request.request, {basedir});
38-
} catch (error) {
39-
// TODO This is not good! But the `debug` package tries to require `supports-color` without declaring it in its
40-
// package.json, and Webpack accepts this because it's in a try/catch, so we need to do it as well.
41-
resolved = false;
42-
}
43-
44-
this.doResolve(['resolved'], Object.assign({}, request, {
45-
path: resolved,
46-
}), '', callback);
47-
});
16+
if (name === `natives`) {
17+
delete ret.punycode;
4818
}
19+
20+
return ret;
4921
};
5022

51-
const pnpOptions = fs.existsSync(`${__dirname}/../.pnp.js`) ? {
52-
resolve: {
53-
plugins: [
54-
PnpResolver,
55-
]
56-
},
57-
resolveLoader: {
58-
plugins: [
59-
PnpResolver,
60-
]
61-
}
62-
} : {};
23+
const version = require('../package.json').version;
24+
const basedir = path.join(__dirname, '../');
25+
const babelRc = JSON.parse(fs.readFileSync(path.join(basedir, '.babelrc'), 'utf8'));
6326

6427
// Use the real node __dirname and __filename in order to get Yarn's source
6528
// files on the user's system. See constants.js
@@ -119,13 +82,12 @@ const compiler = webpack({
11982
},
12083
target: 'node',
12184
node: nodeOptions,
122-
... pnpOptions,
12385
});
12486

12587
compiler.run((err, stats) => {
12688
const fileDependencies = stats.compilation.fileDependencies;
12789
const filenames = fileDependencies.map(x => x.replace(basedir, ''));
128-
console.log(util.inspect(filenames, {maxArrayLength: null}));
90+
//console.log(util.inspect(filenames, {maxArrayLength: null}));
12991
});
13092

13193
//
@@ -171,7 +133,6 @@ const compilerLegacy = webpack({
171133
},
172134
target: 'node',
173135
node: nodeOptions,
174-
... pnpOptions,
175136
});
176137

177138
compilerLegacy.run((err, stats) => {

0 commit comments

Comments
 (0)