Skip to content

Commit 2317d58

Browse files
authored
Merge pull request #91 from CodinGame/fix-esm-strict
Fix esm strict
2 parents 5972242 + a3f35d0 commit 2317d58

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

rollup.config.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ const extensions = ['.js', '.ts']
2929
// But the polyfill doesn't export all required fields and make the build crash
3030
const IGNORED_NODE_POLYFILLS = new Set(['os', 'fs'])
3131

32+
function isExternal (source: string) {
33+
if (IGNORED_NODE_POLYFILLS.has(source)) {
34+
return true
35+
}
36+
if (source.startsWith('extensions/')) {
37+
return false
38+
}
39+
if (externals.some(external => source === external || source.startsWith(`${external}/`))) {
40+
return true
41+
}
42+
return false
43+
}
44+
3245
export default rollup.defineConfig({
3346
cache: false,
3447
input: {
@@ -38,21 +51,6 @@ export default rollup.defineConfig({
3851
annotations: true,
3952
moduleSideEffects: false
4053
},
41-
external: function isExternal (source, importer, isResolved) {
42-
if (IGNORED_NODE_POLYFILLS.has(source)) {
43-
return true
44-
}
45-
if (isResolved) {
46-
return false
47-
}
48-
if (source.startsWith('extensions/')) {
49-
return false
50-
}
51-
if (externals.some(external => source === external || source.startsWith(`${external}/`))) {
52-
return true
53-
}
54-
return false
55-
},
5654
output: [{
5755
chunkFileNames: '[name].js',
5856
hoistTransitiveImports: false,
@@ -62,6 +60,24 @@ export default rollup.defineConfig({
6260
preserveModulesRoot: 'src'
6361
}],
6462
plugins: [
63+
{
64+
name: 'external-resolver',
65+
resolveId (id) {
66+
if (id === 'vscode-languageclient/browser') {
67+
return {
68+
id: 'vscode-languageclient/browser.js',
69+
external: 'absolute'
70+
}
71+
}
72+
if (isExternal(id)) {
73+
return {
74+
id,
75+
external: true
76+
}
77+
}
78+
return undefined
79+
}
80+
},
6581
typescript({
6682
noEmitOnError: true
6783
}),

0 commit comments

Comments
 (0)