forked from stenciljs/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin-helper.ts
More file actions
78 lines (70 loc) · 1.74 KB
/
Copy pathplugin-helper.ts
File metadata and controls
78 lines (70 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { buildError, relative } from '@utils';
import type * as d from '../../declarations';
import type { BundlePlatform } from './bundle-interface';
export const pluginHelper = (config: d.ValidatedConfig, builtCtx: d.BuildCtx, platform: BundlePlatform) => {
return {
name: 'pluginHelper',
resolveId(importee: string, importer: string): null {
if (/\0/.test(importee)) {
// ignore IDs with null character, these belong to other plugins
return null;
}
if (importee.endsWith('/')) {
importee = importee.slice(0, -1);
}
if (builtIns.has(importee)) {
let fromMsg = '';
if (importer) {
fromMsg = ` from ${relative(config.rootDir, importer)}`;
}
const diagnostic = buildError(builtCtx.diagnostics);
diagnostic.header = `Node Polyfills Required`;
diagnostic.messageText = `For the import "${importee}" to be bundled${fromMsg}, ensure the "rollup-plugin-node-polyfills" plugin is installed and added to the stencil config plugins (${platform}). Please see the bundling docs for more information.
Further information: https://stenciljs.com/docs/module-bundling`;
}
return null;
},
};
};
const builtIns = new Set([
'child_process',
'cluster',
'dgram',
'dns',
'module',
'net',
'readline',
'repl',
'tls',
'assert',
'console',
'constants',
'domain',
'events',
'path',
'punycode',
'querystring',
'_stream_duplex',
'_stream_passthrough',
'_stream_readable',
'_stream_writable',
'_stream_transform',
'string_decoder',
'sys',
'tty',
'crypto',
'fs',
'Buffer',
'buffer',
'global',
'http',
'https',
'os',
'process',
'stream',
'timers',
'url',
'util',
'vm',
'zlib',
]);