Skip to content

Commit

Permalink
Export types, add better error
Browse files Browse the repository at this point in the history
  • Loading branch information
hansottowirtz committed Aug 24, 2023
1 parent ae430a7 commit d4e3996
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
{
"name": "serverless-externals-plugin",
"version": "0.4.0",
"version": "0.4.1",
"description": "Only include external node modules and their dependencies in Serverless",
"type": "module",
"main": "./build/esm/index.js",
"exports": {
".": {
"require": "./build/cjs/index-cjs.js",
"types": "./build/esm/index.d.ts",
"default": "./build/esm/index.js"
},
"./rollup-plugin": {
"require": "./build/cjs/rollup-plugin.js",
"types": "./build/esm/rollup-plugin.d.ts",
"default": "./build/esm/rollup-plugin.js"
},
"./serverless-plugin": {
"require": "./build/cjs/serverless-plugin.js",
"types": "./build/esm/serverless-plugin.d.ts",
"default": "./build/esm/serverless-plugin.js"
}
},
Expand Down
4 changes: 4 additions & 0 deletions src/rollup-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ const rollupPlugin = (
name: "serverless-externals-plugin",
async buildStart() {
graph = await buildDependencyGraph(rootPath);
if (workspaceName && !graph.workspaces.has(workspaceName)) {
this.error(`No workspace found for: ${workspaceName}`);
}
main = workspaceName ? resolveLink(graph.edgesOut.get(workspaceName).to) : graph;
if (workspaceName) {
const relativeMainInventory = relativeInventoryFromNode(main);
Expand Down Expand Up @@ -193,6 +196,7 @@ const rollupPlugin = (
if (resolvedConfig.packaging?.exclude?.includes(originalImportModuleRoot)) continue;
const node = mergedInventory.get(`node_modules/${originalImportModuleRoot}`);
if (!node) {
if (originalImportee.startsWith("node:")) continue;
this.warn(`No module found for: ${prettyJson(originalImportee)}`);
continue;
}
Expand Down

0 comments on commit d4e3996

Please sign in to comment.