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

Wrap creation of package.json script in /// #78

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

philliplakis
Copy link
Contributor

There is an issue with the creation of the package.json for the CJS module.
When importing it the following error is thrown:
SyntaxError: Error parsing /Users/philliplakis/Documents/GitHub/allstar-graphql-data/node_modules/csgo-sharecode/dist/cjs/package.json: Expected property name or '}' in JSON at position 2

Steps to reproduce:

yarn add csgo-sharecodes

New TS file:

// # sharecode.ts
import { decodeMatchShareCode } from "csgo-sharecode";

export const SharecodeValidator = (sharecode: string) => {
  try {
    console.log(`sharecode:`, sharecode);
    const matchInformation = decodeMatchShareCode(sharecode);
    console.log(matchInformation);
    return sharecode;
  } catch {
    console.log("Invalid Sharecode");
    return false;
  }
};
npx ts-node ./sharecode.ts

this is due to the package.json being written without quotes in the ./dist/cjs/package.json

{ type: commonjs }

The changes I made are in the script of the package on the build:cjs

"build:cjs": "tsc --module CommonJS --outDir dist/cjs && echo { \"\\\"type\"\\\": \"\\\"commonjs\"\\\" } > ./dist/cjs/package.json",

this outputs the correct format for the package.json

{ "type": "commonjs" }

@akiver akiver merged commit 268b6a7 into akiver:main Dec 13, 2023
1 check passed
@akiver
Copy link
Owner

akiver commented Dec 13, 2023

Thx!

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.

2 participants