File tree Expand file tree Collapse file tree 1 file changed +25
-15
lines changed Expand file tree Collapse file tree 1 file changed +25
-15
lines changed Original file line number Diff line number Diff 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
3030const 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+
3245export 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,18 @@ export default rollup.defineConfig({
6260 preserveModulesRoot : 'src'
6361 } ] ,
6462 plugins : [
63+ {
64+ name : 'external-resolver' ,
65+ resolveId ( id ) {
66+ if ( isExternal ( id ) ) {
67+ return {
68+ id,
69+ external : true
70+ }
71+ }
72+ return undefined
73+ }
74+ } ,
6575 typescript ( {
6676 noEmitOnError : true
6777 } ) ,
You can’t perform that action at this time.
0 commit comments