unplugin / unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup
MIT License
3.29k stars 198 forks source link

之前使用版本 0.7.1 升级0.8.5版本之后编译报错 Cannot read properties of null (reading 'startsWith') #187

Closed wowoName closed 2 years ago

wowoName commented 2 years ago

\node_modules\unplugin-auto-import\node_modules\unplugin\dist\webpack\loaders\transform.js??ref--39-0!\node_modules\unplugin-vue-components\node_modules\unplugin\dist\webpack\loaders\transform.js??ref--40-0!\node_modules\unplugin-auto-import\node_modules\unplugin\dist\webpack\loaders\transform.js??ref--39-0\node_modules\unplugin-vue-components\node_modules\unplugin\dist\webpack\loaders\transform.js??ref--40-0!\node_modules\cache-loader\dist\cjs.js??ref--13-0!\node_modules\babel-loader\lib\index.js!\node_modules\cache-loader\dist\cjs.js??ref--1-0!\node_modules\vue-loader-v16\dist\index.js??ref--1-1!*** Cannot read properties of null (reading 'startsWith')

itskaiway commented 2 years ago

一样的问题,暂时把选项中的imports: ['vue']屏蔽,批量修改下页面导入vue的路径,错误消失,等待大佬解决吧

antfu commented 2 years ago

We temporarily close this due to the lack of enough information. Please provide a minimal reproduction to reopen the issue. Thanks.

Why reproduction is required

exherb commented 2 years ago

maybe related to https://github.com/dart-lang/sdk/issues/38967

https://github.com/antfu/unplugin-auto-import/blob/8b70cffee957b87a1c699c3c42d3ba0b986e1193/src/core/ctx.ts#L68

it's failed at

{
  name: 'constructor',
  as: 'constructor',
  ___dart_isolate_tags_: [Object: null prototype] { _ZxYxX_0_: 1 }
}
antfu commented 2 years ago

How's it sneak into the import list?

exherb commented 2 years ago

no idea, but I add some log and print i with this.

exherb commented 2 years ago

I have find the root cause of this issue.

const unpluginResolver: ComponentResolver = {
    type: "component",
    resolve(name: string): ComponentResolveResult {
      const p = {"a": import("@/xxx/a")}[name];
      if (p != null) {
        return p;
      }
  };

when name is constructor or toString, it returns func.