break-stuff / cem-plugin-jet-brains-ide-integration

A custom elements manifest analyzer plugin to generate configuration files for web component integration with JetBrains IDEs
MIT License
11 stars 0 forks source link

Troubles with loading the plugin #4

Closed SavoInfostream closed 1 year ago

SavoInfostream commented 1 year ago

Can you help me with configuring this properly;

Here's my script entry:

  "scripts": {
    "custom-elements-manifest": "custom-elements-manifest analyze --config ./custom-elements-manifest.config.js"
  },

Which results in: You are using es module syntax in a config loaded as CommonJS module. Use require/module.exports syntax, or load the file as es module by using the .mjs file extension or by setting type="module" in your package.json.

Setting extension to .mjs I get:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'cem-plugin-jet-brains-ide-integration' imported from C:...\custom-elements-manifest.config.mjs

And finally changing the import name to custom-element-jet-brains-integration I get: SyntaxError: Unexpected token  in JSON at position 0 at JSON.parse () at file:///C:.../node_modules/custom-element-jet-brains-integration/dist/index.js:247:24 at ModuleJob.run (node:internal/modules/esm/module_job:194:25) Which is this line: var packageJson = JSON.parse(fs2.readFileSync("package.json", "utf8"));

What to do?

break-stuff commented 1 year ago

Thank you for reaching out! Can you show me how you are implementing the plugin? Make sure you are using customElementJetBrainsPlugin and not generateJetBrainsWebTypes.

SavoInfostream commented 1 year ago
import { customElementJetBrainsPlugin } from "custom-element-jet-brains-integration";

const options = {
};

// module.exports = {
//     outdir: "./wwwroot",
//     plugins: [
//         customElementJetBrainsPlugin(options)
//     ]
// }

export default {
    outdir: "./",
    plugins: [
        customElementJetBrainsPlugin(options)
    ]
};
SavoInfostream commented 1 year ago

I debug it and it was caused by BOM in package.json. Something like this happened to me on Windows a few times.