Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial clone + build fails on module resolution for zotero-types #1

Closed
whacked opened this issue Aug 31, 2022 · 3 comments
Closed

Comments

@whacked
Copy link

whacked commented Aug 31, 2022

Hi, I'm following the template instructions step-by-step. Pardon my basic questions; I am not familiar with esbuild.

I have:

  1. cloned the respository
  2. modified package.json
  3. run npm install
  4. run npm run build

at which point, the build fails with these errors:

[Build] BUILD_DIR=builds, VERSION=0.0.0, BUILD_TIME=2022-08-31 10:26:14
✘ [ERROR] Could not resolve "zotero-types"

    src/index.ts:1:23:
      1 │ import { Zotero } from "zotero-types";
        ╵                        ~~~~~~~~~~~~~~

  You can mark the path "zotero-types" as external to exclude it from the bundle, which will remove
  this error.

✘ [ERROR] Could not resolve "zotero-types"

    src/views.ts:1:28:
      1 │ import { XUL, Zotero } from "zotero-types";
        ╵                             ~~~~~~~~~~~~~~

  You can mark the path "zotero-types" as external to exclude it from the bundle, which will remove
  this error.

✘ [ERROR] Could not resolve "zotero-types"

    src/events.ts:1:23:
      1 │ import { Zotero } from "zotero-types";
        ╵                        ~~~~~~~~~~~~~~

  You can mark the path "zotero-types" as external to exclude it from the bundle, which will remove
  this error.

Additional information:

  • zotero-types exists in node_modules, among 348 total folders in node_modules following npm install. zotero-types contains README.md, package.json, and index.d.ts
  • following the error message, I modify build.js this way:
await esbuild
  .build({
    entryPoints: ["src/index.ts"],
    external: ["zotero-types"],       // <--- add this line
    bundle: true,
    // Entry should be the same as add ...
    outfile: path.join(buildDir, "addo ...
    // minify: true,                  
  })
  .catch(() => process.exit(1));      

and it appears to build ok. Is this the correct fix?

system information

[nix-shell:/tmp/zotero-addon-template]$ echo $NODE_PATH
/tmp/zotero-addon-template/node_modules

[nix-shell:/tmp/zotero-addon-template]$ node --version
v18.7.0

[nix-shell:/tmp/zotero-addon-template]$ npm --version
8.15.0

thank you for your work

@windingwind
Copy link
Owner

Sorry, this is a bug caused by the upper-stream dependency zotero-types and I have just fixed it.

Making it external might not be the right way. Please pull the latest changes of this repo and update the npm package zotero-types. Make sure it is >= v0.0.3.

@whacked
Copy link
Author

whacked commented Sep 5, 2022

Confirmed that updating to zotero-types 0.0.3 and npm build without the external hack succeeds.

thanks!

@whacked whacked closed this as completed Sep 5, 2022
@windingwind
Copy link
Owner

Just to remind, the bootstrap mode is now available. The overlay mode will no longer be supported in Zotero 7(though may be years later). If you just started, please consider switching to bootstrap mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants