iabtcf-es: CmpApiModel missing in index.ts

Version 1.5.5

Module (cmpapi, cli, stub, or testing) cmpapi

Describe with reproduction steps – What is the expected behavior? Unresolved dependencies

When i change the CmpApiModel path (used with version 1.3.0) from

import { CmpApiModel } from '@iabtcf/cmpapi/lib/CmpApiModel'; to import { CmpApiModel } from "@iabtcf/cmpapi/lib/mjs/CmpApiModel";

then there are warnings from rollupjs module bundler (!) Plugin node-resolve: Could not resolve import "@iabtcf/cmpapi/lib/mjs/CmpApiModel"

and webpack Module not found: Error: Package path ./lib/mjs/CmpApiModel is not exported from package /Users/john/workspace/example/node_modules/@iabtcf/cmpapi (see exports field in /Users/john/workspace/example/node_modules/@iabtcf/cmpapi/package.json)

Is there a reason why the class is not exported? Is it possible to add CmpApiModel to the index.ts?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@sewolf ok, so this is what we will do then. I will merge in the PR that Marco created and a pre-release version of the library will contain those changes. Unfortunately, I won’t be able to have those changes into an actual release until near the beginning of January. I am the only one who manages the library and I will be going on vacation soon.

So you will just be including @iabtcf/cmpapi@next into your project. Come the new year, I will tag you in a comment in this ticket when the actual release is made.

@Marco-Prontera, thanks for the quick response but I’d like to hold off on merging that PR.

@sewolf, we need a bit more information. I can see that CmpApiModel.ts is available in the node_modules folder in the exact path that you specified for both common js and ESM. It may not be declared in index.ts but it is still an exported class. I was able to run it locally and build with no issues.

Screen Shot 2022-11-29 at 9 53 12 AM

Are you getting this error when you are running a dev server locally or when you are building? Have you tried importing as follows import { CmpApiModel } from '@iabtcf/cmpapi/lib/mjs/CmpApiModel.js'?

@shortaflip I have not removed any files from the index.ts. But we can add it without any problem Schermata 2022-11-28 alle 19 10 59