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

Docs(Code Issue): Code Issue in /admin/configuration #7187

Open
1 of 2 tasks
nyctonio opened this issue May 1, 2024 · 1 comment · Fixed by #7188
Open
1 of 2 tasks

Docs(Code Issue): Code Issue in /admin/configuration #7187

nyctonio opened this issue May 1, 2024 · 1 comment · Fixed by #7188

Comments

@nyctonio
Copy link

nyctonio commented May 1, 2024

Preliminary Checks

Issue Summary

11:04:57 AM [@medusajs/admin] An error occured while trying to load your custom Webpack config. See the error below for details:

import { withCustomWebpackConfig } from "@medusajs/admin";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1274:20)
at Module._compile (node:internal/modules/cjs/loader:1320:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
at Module.load (node:internal/modules/cjs/loader:1197:32)
at Module._load (node:internal/modules/cjs/loader:1013:12)
at Module.require (node:internal/modules/cjs/loader:1225:19)
at require (node:internal/modules/helpers:177:18)
at getCustomWebpackConfig (/Users/nio/official/medusa/medusa-brands/node_modules/@medusajs/admin/node_modules/@medusajs/admin-ui/dist/index.js:45:5741)
at async develop (/Users/nio/lifease/trash/eivape/official/medusa/medusa-eivape-brands/node_modules/@medusajs/admin/node_modules/@medusajs/admin-ui/dist/index.js:45:7376)
11:04:57 AM [@medusajs/admin] Exiting process

How can this issue be resolved?

No response

Are you interested in working on this issue?

  • I would like to fix this issue
@shahednasser
Copy link
Member

Thank you for submitting this issue! The example in the documentation should use CommonJS rather than ESM (so require instead of import.) So something like this:

const withCustomWebpackConfig = require("@medusajs/admin").withCustomWebpackConfig

module.exports = withCustomWebpackConfig((config, webpack) => {
  config.plugins.push(
    new webpack.DefinePlugin({
    "process.env": {
      NODE_ENV: JSON.stringify("production"),
      API_URL: 
        JSON.stringify("https://api.medusa-commerce.com"),
    },
    })
  )
  
  return config
})

Will open a PR to fix this

shahednasser added a commit that referenced this issue May 1, 2024
Fix the code snippet in the admin's webpack custom configurations to use CJS rather than ESM

Closes #7187
shahednasser added a commit that referenced this issue May 8, 2024
* docs: fix code snippet for webpack custom configurations

Fix the code snippet in the admin's webpack custom configurations to use CJS rather than ESM

Closes #7187

* fix lint error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants