Skip to content

Upgrade all dependencies#58

Merged
Naramsim merged 2 commits into
PokeAPI:masterfrom
lbineau:master
Sep 4, 2024
Merged

Upgrade all dependencies#58
Naramsim merged 2 commits into
PokeAPI:masterfrom
lbineau:master

Conversation

@lbineau

@lbineau lbineau commented Aug 29, 2024

Copy link
Copy Markdown

There are a lot of security issues raised by this package so I've upgraded all dependencies.
Only chai packages couldn't be upgraded to the latest major version because it is using ESM. I only sticked with the latest minor version.
I've npm run test and npm run build and everything seems to work.

@Naramsim

Copy link
Copy Markdown
Member

Hi, could you also bump the patch version of the package?

@Naramsim Naramsim merged commit 2a691f9 into PokeAPI:master Sep 4, 2024
@Naramsim

Naramsim commented Sep 4, 2024

Copy link
Copy Markdown
Member

Thanks!

Naramsim referenced this pull request Sep 6, 2024
@Naramsim

Naramsim commented Sep 6, 2024

Copy link
Copy Markdown
Member

Hi! A user seems to have a problem with this version 1.2.5, @isackender. Coul it be possible that the package is broken?

Preventively I unpublished the 1.2.5 from NPM. Still the lib can be found in this GH repo under the dist folder.

@isackender

isackender commented Sep 6, 2024

Copy link
Copy Markdown

Hi, yes, as @Naramsim pointed out, my project broke two days ago. My code is:

<script src="https://unpkg.com/[email protected]/dist/index.js"></script>

<!-- Service worker -->
<script src="pokeapi-js-wrapper-sw.js"></script>

<!-- Initialize js wrapper -->
<script>
    const customOptions = {
        protocol: "https",
        versionPath: "/api/v2/",
        cache: true,
        timeout: 5 * 1000, // 5s
        cacheImages: true
    };
    const P = new Pokedex.Pokedex(customOptions);
</script>

<!-- Project code -->
<script src="/scripts/main.js"></script>

Which gives me this error (using Firefox):

Uncaught ReferenceError: require is not defined
    23          https://unpkg.com/[email protected]/dist/index.js:2
    n           https://unpkg.com/[email protected]/dist/index.js:2
    801         https://unpkg.com/[email protected]/dist/index.js:2
    n           https://unpkg.com/[email protected]/dist/index.js:2
    737         https://unpkg.com/[email protected]/dist/index.js:2
    n           https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
index.js:2:61271

When I switch to a previous version it works again perfectly (1.2.3 or 1.2.4 work fine).

<script src="https://unpkg.com/[email protected]/dist/index.js"></script>

@climaxmba

climaxmba commented Sep 6, 2024

Copy link
Copy Markdown
Contributor

Hi, yes, as @Naramsim pointed out, my project broke two days ago. My code is:

<script src="https://unpkg.com/[email protected]/dist/index.js"></script>

<!-- Service worker -->
<script src="pokeapi-js-wrapper-sw.js"></script>

<!-- Initialize js wrapper -->
<script>
    const customOptions = {
        protocol: "https",
        versionPath: "/api/v2/",
        cache: true,
        timeout: 5 * 1000, // 5s
        cacheImages: true
    };
    const P = new Pokedex.Pokedex(customOptions);
</script>

<!-- Project code -->
<script src="/scripts/script.js"></script>

Which gives me this error (using Firefox):

Uncaught ReferenceError: require is not defined
    23          https://unpkg.com/[email protected]/dist/index.js:2
    n           https://unpkg.com/[email protected]/dist/index.js:2
    801         https://unpkg.com/[email protected]/dist/index.js:2
    n           https://unpkg.com/[email protected]/dist/index.js:2
    737         https://unpkg.com/[email protected]/dist/index.js:2
    n           https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
    <anonymous> https://unpkg.com/[email protected]/dist/index.js:2
index.js:2:61271

When I switch to a previous version it works again perfectly (1.2.3 or 1.2.4 work fine).

<script src="https://unpkg.com/[email protected]/dist/index.js"></script>

I've seen something like this when I was using a React package. Uninstalling or downgrading the broken dependency in this package should fix it.

@Naramsim

Naramsim commented Sep 6, 2024

Copy link
Copy Markdown
Member

I remember I had issues upgrading axios, because maybe it became a pure ESM package. Maybe that's the issue

@lbineau

lbineau commented Sep 9, 2024

Copy link
Copy Markdown
Author

@Naramsim @climaxmba @isackender,
After spending hours trying to understand why it outputs require in the UMD module and trying various config, I think I understood the issue.

Removing target: 'node' or switching it to target: 'web' properly remove any node related code (require()) and make it work properly.

Is this package supposed to be used in Node/browser/both?
I'll be happy to create PR if it is supposed to work with browsers only.

Error target: 'node'
node target showing a console error: require is undefined

Success target: 'web'
web target showing a console.log success

@climaxmba

climaxmba commented Sep 9, 2024

Copy link
Copy Markdown
Contributor

Sure @lbineau, this package is meant for the browser only. There is a different package that's meant for Node.

@lbineau

lbineau commented Sep 9, 2024

Copy link
Copy Markdown
Author

Here you go #61

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

Successfully merging this pull request may close these issues.

5 participants