vendure-ecommerce/vendure-plus-issues

Bug: Advanced-search-plugin 1.0.2 has `src` in build dir

Closed this issue · 4 comments

The advanced search plugin v1.0.2 has src in build dir, so the package doesn't have a default export. Maybe an import from outside of src was added somewhere, causing TS to include src in the build dir?

image

So all imports in consuming projects need to be rewritten:

- import { AdvancedSearchPlugin } from "@vendure-plus/advanced-search-plugin";
+ import { AdvancedSearchPlugin } from "@vendure-plus/advanced-search-plugin/src";

Other, probably related, errors I am experiencing:

Vitest throws this error:

 FAIL  test/e2e.spec.ts [ test/e2e.spec.ts ]
Error: Parse failure: Unexpected token (1:7)
At file: /node_modules/@vendure-plus/advanced-search-plugin/src/lib/generated-admin-types.ts
Contents of line 1: export type Maybe<T> = T;
 ❯ ssrTransformScript node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53776:15
 ❯ ssrTransform node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53751:12
 ❯ Object.ssrTransform node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63307:20
 ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53422:24

yarn tsc works fine, but running the compiled code then gives me:

Error: Cannot find module '@vendure-plus/advanced-search-plugin/src/lib/service/search-index.service'
Require stack:
- /home/martijn/git/huidpraktijkshop/dist/plugins/trigger-search/trigger-search-plugin.js
- /home/martijn/git/huidpraktijkshop/dist/vendure-config.js
- /home/martijn/git/huidpraktijkshop/dist/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/home/martijn/git/huidpraktijkshop/dist/plugins/trigger-search/trigger-search-plugin.js:13:32)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/martijn/git/huidpraktijkshop/dist/plugins/trigger-search/trigger-search-plugin.js',
    '/home/martijn/git/huidpraktijkshop/dist/vendure-config.js',
    '/home/martijn/git/huidpraktijkshop/dist/index.js'
  ]
}

Thanks for the report. Yes looks like a bad import might have caused this. Will rectify asap.

Please try v1.0.3 and let me know if that fixes things. The issue was actually bad config for npm publishing.

1.0.3 seems to work, thanks for the quick fix 🦾 We also use some deep imports that are now imported from dist, where it was src before, but that isn't a problem:

// In 1.0.1 we did
- import { SearchIndexService } from "@vendure-plus/advanced-search-plugin/src/lib/service/search-index.service";
// in 1.0.3 we do
+ import { SearchIndexService } from "@vendure-plus/advanced-search-plugin/dist/lib/service/search-index.service";

Ah ok yeah that's good to know. The root cause of this is that I have extracted this plugin into a new repo and in doing so a few things got changed around about the publishing flow.