1 | const {warn} = require('./log');
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | const UNAVAIABLE_CORE_MODULES = [
|
17 | 'child_process',
|
18 | 'cluster',
|
19 | 'dgram',
|
20 | 'dns',
|
21 |
|
22 | 'net',
|
23 | 'readline',
|
24 | 'repl',
|
25 | 'tls',
|
26 | 'worker_thread'
|
27 | ];
|
28 |
|
29 | const EMPTY_MODULE = 'define(function(){return {};});';
|
30 |
|
31 | module.exports = function(moduleId, resolve) {
|
32 |
|
33 | if (['crypto', 'https', 'os', 'path', 'stream', 'timers', 'tty', 'vm'].indexOf(moduleId) !== -1) {
|
34 | return {name: moduleId, location: resolve(`${moduleId}-browserify`)};
|
35 | }
|
36 |
|
37 | if (moduleId === 'domain') {
|
38 | warn('core Node.js module "domain" is deprecated');
|
39 | return {name: 'domain', location: resolve('domain-browser')};
|
40 | }
|
41 |
|
42 | if (moduleId === 'http') {
|
43 | return {name: 'http', location: resolve('stream-http')};
|
44 | }
|
45 |
|
46 | if (moduleId === 'querystring') {
|
47 | return {name: 'querystring', location: resolve('querystring-browser-stub')};
|
48 | }
|
49 |
|
50 | if (moduleId === 'sys') {
|
51 | warn('core Node.js module "sys" is deprecated, the stub is disabled in CLI bundler due to conflicts with "util"');
|
52 | return EMPTY_MODULE;
|
53 | }
|
54 |
|
55 | if (moduleId === 'zlib') {
|
56 | return {name: 'zlib', location: resolve('browserify-zlib')};
|
57 | }
|
58 |
|
59 | if (moduleId === 'fs') {
|
60 | return {name: 'fs', location: resolve('fs-browser-stub')};
|
61 | }
|
62 |
|
63 | if (UNAVAIABLE_CORE_MODULES.indexOf(moduleId) !== -1) {
|
64 | return EMPTY_MODULE;
|
65 | }
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | if (moduleId === '__ignore__') {
|
71 | return EMPTY_MODULE;
|
72 | }
|
73 | };
|