Skip to content

🐛 [BUG] Error when used with Next.js #233

@Chen-Zhihui

Description

@Chen-Zhihui

🐛 Bug description [Please make everyone to understand it]

Please provide a link by forking these links LarkMap or GitHub repo, a minimal reproduction.

"use client"
import type { LarkMapProps } from '@antv/larkmap';
import { LarkMap } from '@antv/larkmap';
import React from 'react';

const config: LarkMapProps = {
    mapType: 'Gaode',
    mapOptions: {
        style: 'light',
        center: [120.210792, 30.246026],
        zoom: 9,
        // token: '你申请的 Key',
    },
};

export default function L7Map() {
    return (
        <LarkMap {...config} style={{ height: '300px' }}>
            <h2 style={{ position: 'absolute', left: '10px' }}>LarkMap</h2>
        </LarkMap>
    )
}

📷 Step to reproduce

next.config.js

const webpack = require('webpack');
const withLess = require('next-with-less');

const nextConfig = {
    reactStrictMode: true,
    webpack: config => {
      config.plugins.push(
        new webpack.DefinePlugin({
          CESIUM_BASE_URL: JSON.stringify('cesium'),
        }),
      );
      return config;
    },
    // experimental: true
    experimental : {
      esmExternals: 'loose',
    }
}

module.exports = withLess(nextConfig)

Error message reported by Next.js

- error ./node_modules/@antv/larkmap/es/components/ContextMenu/index.less
Global CSS cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-npm
Location: node_modules\@antv\larkmap\es\components\ContextMenu\index.js

🏞 Expected result

🚑 Any additional [like screenshots]

  • LarkMap Version: latest
  • Platform: windows and linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions