Skip to content

Commit

Permalink
assorted fixes (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Jun 16, 2020
1 parent 806b949 commit 6b1eba6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/09-troubleshooting.md
Expand Up @@ -9,7 +9,7 @@

Some packages are written with dependencies on Node.js built-in modules. This is a problem on the web, since Node.js built-in modules don't exist in the browser. For example, `import 'path'` will run just fine in Node.js but would fail in the browser.

To solve this issue, you can either replace the offending package ([pika.dev](https://pika.dev/) is a great resource for web-friendly packages) or add Node.js polyfill support:
**To solve this issue:** you can either replace the offending package ([pika.dev](https://pika.dev/) is a great resource for web-friendly packages) or add Node.js polyfill support:

```js
// snowpack.config.js
Expand Down
7 changes: 2 additions & 5 deletions src/commands/install.ts
Expand Up @@ -160,7 +160,7 @@ function resolveWebDependency(dep: string): DependencyLoc {
// Oh well, was worth a try
}
}
if (!depManifest) {
if (!depManifestLoc || !depManifest) {
throw new ErrorWithHint(
`Package "${dep}" not found. Have you installed it?`,
depManifestLoc ? chalk.italic(depManifestLoc) : '',
Expand Down Expand Up @@ -199,7 +199,7 @@ function resolveWebDependency(dep: string): DependencyLoc {
}
return {
type: 'JS',
loc: path.join(depManifestLoc || '', '..', foundEntrypoint),
loc: require.resolve(path.join(depManifestLoc || '', '..', foundEntrypoint)),
};
}

Expand Down Expand Up @@ -279,9 +279,6 @@ export async function install(
try {
const {type: targetType, loc: targetLoc} = resolveWebDependency(installSpecifier);
if (targetType === 'JS') {
if (isSinglePackageMode && !checkIsEsModule(targetLoc)) {
autoDetectNamedExports.push(installSpecifier);
}
installEntrypoints[targetName] = targetLoc;
importMap.imports[installSpecifier] = `./${targetName}.js`;
Object.entries(installAlias)
Expand Down
2 changes: 1 addition & 1 deletion src/rollup-plugin-catch-unresolved.ts
Expand Up @@ -19,7 +19,7 @@ export function rollupPluginCatchUnresolved(): Plugin {
} else {
this.warn({
id: importer,
message: `"${id}" could not be resolved.`,
message: `"${id}" could not be resolved. (Is it installed?)`,
});
}
return false;
Expand Down

0 comments on commit 6b1eba6

Please sign in to comment.