Type of Change
Summary
Testing in a side project, and a custom element like this
import '../components/card/card.native.js';
import fetch from 'node-fetch';
export default class ArtistsPage extends HTMLElement {
async connectedCallback() {
if (!this.shadowRoot) {
const artists = await fetch('https://www.analogstudios.net/api/artists').then(resp => resp.json());
const html = artists.map(artist => {
return `
<wc-card>
<h2 slot="title">${artist.name}</h2>
<img slot="image" src="${artist.imageUrl}" alt="${artist.name}"/>
</wc-card>
`;
}).join('');
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = html;
}
}
}
will cause an unhandled exception trying to use fs.readFile on node-fetch
moduleURL: URL {
href: 'file:///Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/pages/node-fetch',
origin: 'null',
protocol: 'file:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/pages/node-fetch',
search: '',
searchParams: URLSearchParams {},
hash: ''
}
}
(node:88140) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/pages/node-fetch'
Details
The issue is we blindly try and read all dependencies, even bare specifiers, which are typically node modules deps and should be left to the Node resolution algorithm and not walked with acorn.
That said, this may only be a patch, since I think in the context of #38 , will we have to support walking node modules? 🤔
Type of Change
Summary
Testing in a side project, and a custom element like this
will cause an unhandled exception trying to use
fs.readFileonnode-fetchmoduleURL: URL { href: 'file:///Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/pages/node-fetch', origin: 'null', protocol: 'file:', username: '', password: '', host: '', hostname: '', port: '', pathname: '/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/pages/node-fetch', search: '', searchParams: URLSearchParams {}, hash: '' } } (node:88140) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/pages/node-fetch'Details
The issue is we blindly try and read all dependencies, even bare specifiers, which are typically node modules deps and should be left to the Node resolution algorithm and not walked with acorn.
That said, this may only be a patch, since I think in the context of #38 , will we have to support walking node modules? 🤔