GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lowcode-engine/docs/docs/faq/faq020.md at main · Devancn/lowcode-engine

Expand file tree

/

faq020.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
44 lines (37 loc) · 1.42 KB
/

faq020.md

Copy path

File metadata and controls

44 lines (37 loc) · 1.42 KB
Raw
Copy raw file
Download raw file
Edit and raw actions
title Can't import the named export from non ECMAScript module
sidebar_position 20
tags
FAQ

如果您是自己配置的引擎打包,那么可能会遇到这个问题。

image.png

问题的根源是 code-editor 插件运行时直接依赖了 babel 来完成 jsx 编译,babel 从 7.17.0 开始依赖了使用 ESM 编写的 @ampproject/[email protected]。如果打包工具无法正确处理 ESM,则可能报错。

解决方案 1:锁定 babel 版本

如果您使用了 yarn,那么可以在 package.json 中:

"resolutions": {
    "@babel/core": "~7.16.7",
    "@babel/parser": "~7.16.7",
    "@babel/preset-env": "~7.16.7",
    "@babel/preset-react": "~7.16.7",
    "@babel/standalone": "~7.16.7",
    "@babel/traverse": "~7.16.7",
    "@babel/types": "~7.16.7"
}

解决方案 2:编译层面配置。本例使用 build-script 配置,您可以用类似方法来配置您的 webpack:

module.exports = ({ onGetWebpackConfig }) => {
  // see: https://github.com/ice-lab/build-scripts#%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91
  onGetWebpackConfig((config) => {
    config.module // fixes https://github.com/graphql/graphql-js/issues/1272
      .rule('mjs$')
      .test(/\.mjs$/)
      .include
        .add(/node_modules/)
        .end()
      .type('javascript/auto');
    return config;
  });
};
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.