-
Notifications
You must be signed in to change notification settings - Fork 361
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
Error on types/packageInfo.js -- SyntaxError: Unexpected token 'export' #3374
Comments
Here is an SO question dealing with the same - https://stackoverflow.com/questions/65936222/next-js-syntaxerror-unexpected-token-export Above (and also on the next.js repo), other devs keep on pointing to https://github.com/martpie/next-transpile-modules#readme as a solution for using ESM dependencies |
Thanks for the rapid response, @jacogr . I have installed the module for transpiling, but then another error occurred:
Inside const withTM = require('next-transpile-modules')(['@polkadot/api', '@polkadot/types']);
module.exports = withTM({
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
issuer: {
test: /\.(js|ts)x?$/
},
use: ['@svgr/webpack']
});
return config;
}
}); Any clue? |
In the above, it seems now that since |
supplying
If I need to supply all of them, how many are they? |
Ummm, that is a horrible solution then. It would depend on what is actually used, so |
This is the output of
It is awful if I need to include all of them. Isn't there any workaround? Thank you again for assisting me. |
All the information for compilation is included in the package.json for the bundler -
So really not sure why next ignores all this info. (Especially since there is a drive for packages to publish as esm now that Node is fully on-board) The only option I see in this case is to specify each package with the Plugin (which is terrible since they are granular). If it was me I would do an fs.readDir and dynamically populate the list. (Still horrible, but at least dynamic) Will need to read more about next and their plans in their issue tracker, cannot see that having all esm modules done via a plugin is a long-term solution, at some point basically all will need to go through that route. |
okay, so I have specified each package with the Plugin and the error persists. By doing
I realise that I have mistakenly modified the
which is dumb because such files don't exist. Changing it into:
fix the problem. However, when the transpile module 'reads' other packages which does not contain
Ignoring these packages will bring me back to the same error where metadata is not recognised Since the metadata can not be read by the transpile-module, I think I am revisiting the earlier issue and now I am more clueless as to where to start debugging this. |
The metadata package does have the export map. The build scripts are the same. Is there possibly a version mismatch, ie. the metadata not being the same version as the api and types? |
You're right. metadata and types version is 1.34.1, while api version is 4.4.1, I completely missed that. I have upgraded both to match api version, but the error still persists. |
That is weird, the API types/dependencies only refer to the current version of the metadata. For instance for 4.4.1 - https://github.com/polkadot-js/api/blob/v4.4.1/packages/api/package.json#L18-L31 So if you have them specified explicitly in your package.json, just bump the version there. Alternatively if you only have the API installed (don't see how the dependency should go wrong since the versions are specified in package.json for the same versions), cleaning node_modules and re-installing should do the trick. |
That's it! After making sure that there's no duplication of polkadot packages within the However, now after each page compilation I got this error:
The modules being referred differ depending on which page being compiled, but it is always Was there something that I miss? |
Right, so now I wanted to instantiate the API inside one of my React component using this snippet: const wsProvider = new WsProvider('wss://rpc.myriad.systems/');
94 | console.log('wsProvider:', wsProvider);
> 95 | const api = await ApiPromise.create({
| ^
96 | provider: wsProvider,
97 | types: types
98 | }); but then at line 95 the code breaks and the console logs this error:
|
Multiple instances of @polkadot/wasm-crypto detected
Generally |
Okay, thanks for keeping up with me, you're the best! The I was finally able to find a fix to this, following these steps:
The fourth step had already been discussed before but I can not find the link to the thread. Run with |
This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query. |
Hello everyone, I am new to Polkadot.js so please bear with me.
I am making a Next.js app which tries to connect to a custom blockchain in one of my component (e.g.
wallet.component.tsx
), using the snippets below:However, when I execute my dev script:
ts-node -r dotenv/config --project tsconfig.server.json server/index.ts
it returns an error:
The content of tsconfig.server.json:
and tsconfig.json:
server/index.ts
only contains codes which 'converts' localhost protocol to https. Nothing fancy there.Is this a problem with the package itself or a config error on my ts compiler? Please do let me know if I should address this issue to the next.js repo instead.
Your help is much appreciated, thank you!
The text was updated successfully, but these errors were encountered: