You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just had a weird encounter where Fantasticon refused to parse the .fantasticonrc.js even though it was formatted correctly.
The issue turned out to be with how the package.json was declaring the type of the package. It was set to "module", a default set by Vite create template, which meant that all common .js files needed to have a .cjs extension, I was only able to figure this out after manually adding the console.error(err).
Expected behaviour
Create a --verbose flag or print out a verbose error reporting on traceback and any other useful info i.e.:
user@hostpc:~/git/internal/project$ bun run generate-icons
$ fantasticon
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/user/git/internal/project/.fantasticonrc.js from /home/user/git/internal/project/node_modules/fantasticon/lib/cli/config-loader.js not supported.
.fantasticonrc.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename .fantasticonrc.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/user/git/internal/project/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
at /home/user/git/internal/project/node_modules/fantasticon/lib/cli/config-loader.js:26:20
at Generator.next (<anonymous>)
at fulfilled (/home/user/git/internal/project/node_modules/fantasticon/lib/cli/config-loader.js:5:58) {
code: 'ERR_REQUIRE_ESM'
}
SyntaxError: Unexpected token 'm', "module.exp"... is not valid JSON
at JSON.parse (<anonymous>)
at /home/user/git/internal/project/node_modules/fantasticon/lib/cli/config-loader.js:30:25
at Generator.next (<anonymous>)
at fulfilled (/home/user/git/internal/project/node_modules/fantasticon/lib/cli/config-loader.js:5:58)
Failed parsing configuration at '.fantasticonrc.js'
Actual Behaviour
All I get is Failed parsing configuration at '.fantasticonrc.js', which is needless to say is not helpful.
Also might be a good idea to add .cjs exension to a set of default imports or make this fetch dynamic by using regex.
I had same issue with Failed parsing configuration at '.fantasticonrc.js' but without any additional logs.
As I found the problem was next: there was a path codepoints: require('./icons.json'), in the config but this file did not exist at first run. To solve it I created the icons.json with empty object {}.
As I found the problem was next: there was a path codepoints: require('./icons.json'), in the config but this file did not exist at first run.
Weird NextJS doesn't have anything of that sorts in the config. Or at least not in the default template, perhaps it's something you've inherited from other project?
Just had a weird encounter where Fantasticon refused to parse the
.fantasticonrc.js
even though it was formatted correctly.The issue turned out to be with how the
package.json
was declaring thetype
of the package. It was set to "module", a default set by Vite create template, which meant that all common.js
files needed to have a.cjs
extension, I was only able to figure this out after manually adding theconsole.error(err)
.Expected behaviour
Create a
--verbose
flag or print out a verbose error reporting on traceback and any other useful info i.e.:Actual Behaviour
All I get is
Failed parsing configuration at '.fantasticonrc.js'
, which is needless to say is not helpful.Also might be a good idea to add
.cjs
exension to a set of default imports or make this fetch dynamic by using regex.issue blames:
fantasticon/src/cli/config-loader.ts
Line 21 in 76154ac
fantasticon/src/cli/config-loader.ts
Line 17 in 76154ac
The text was updated successfully, but these errors were encountered: