AFFiNE icon indicating copy to clipboard operation
AFFiNE copied to clipboard

Remove `extensionAlias` from webpack?​

Open Boshen opened this issue 1 year ago • 2 comments

What happened?

https://github.com/toeverything/AFFiNE/blob/3432f355b0e31637a766f2c81f0d0dcbb1967345/packages/frontend/core/.webpack/config.ts#L143-L146

There are some imports in this repo that are doing non-standard things:

https://github.com/toeverything/AFFiNE/blob/3432f355b0e31637a766f2c81f0d0dcbb1967345/packages/common/env/src/global.ts#L6

This causes confusion for toolings, especially for what I'm working on for oxlint --import-plugin :-)

If you need the whole list, this is what oxlint reports because it doesn't understand extension alias.

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[packages/common/env/src/global.ts:6:37]
 5 │
 6 │ import { isDesktop, isServer } from './constant.js';
   ·                                     ───────────────
 7 │ import { UaHelper } from './ua-helper.js';
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[packages/common/env/src/global.ts:7:26]
 6 │ import { isDesktop, isServer } from './constant.js';
 7 │ import { UaHelper } from './ua-helper.js';
   ·                          ────────────────
 8 │
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[packages/backend/server/src/core/auth/next-auth-options.ts:1:31]
 1 │ import { PrismaAdapter } from '@auth/prisma-adapter';
   ·                               ──────────────────────
 2 │ import { FactoryProvider, Logger } from '@nestjs/common';
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
    ╭─[packages/frontend/electron/forge.config.mjs:16:8]
 15 │   productName,
 16 │ } from './scripts/make-env.js';
    ·        ───────────────────────
 17 │
    ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[packages/frontend/i18n/src/scripts/download.ts:7:63]
 6 │
 7 │ import { getAllProjectLanguages, getRemoteTranslations } from './api.js';
   ·                                                               ──────────
 8 │ import { flattenTranslation, type TranslationRes } from './utils.js';
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[packages/frontend/i18n/src/scripts/download.ts:8:57]
 7 │ import { getAllProjectLanguages, getRemoteTranslations } from './api.js';
 8 │ import { flattenTranslation, type TranslationRes } from './utils.js';
   ·                                                         ────────────
 9 │
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[tools/cli/src/util/infra.ts:6:29]
 5 │
 6 │ import { projectRoot } from '../config/index.js';
   ·                             ────────────────────
 7 │
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
    ╭─[packages/common/infra/src/__tests__/migration.spec.ts:9:33]
  8 │
  9 │ import { migrateToSubdoc } from '../blocksuite/index.js';
    ·                                 ────────────────────────
 10 │
    ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[packages/common/env/src/__tests__/is-valid-ip-address.spec.ts:3:34]
 2 │
 3 │ import { isValidIPAddress } from '../is-valid-ip-address.js';
   ·                                  ───────────────────────────
 4 │
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[tools/cli/src/bin/build-core.ts:5:29]
 4 │ import type { BuildFlags } from '../config/index.js';
 5 │ import { projectRoot } from '../config/index.js';
   ·                             ────────────────────
 6 │ import { buildI18N } from '../util/i18n.js';
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[tools/cli/src/bin/build-core.ts:6:27]
 5 │ import { projectRoot } from '../config/index.js';
 6 │ import { buildI18N } from '../util/i18n.js';
   ·                           ─────────────────
 7 │
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[packages/frontend/i18n/src/scripts/api.ts:4:29]
 3 │ // cSpell:ignore Tolgee
 4 │ import { fetchTolgee } from './request.js';
   ·                             ──────────────
 5 │
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[packages/frontend/i18n/src/scripts/sync.ts:5:54]
 4 │
 5 │ import { createsNewKey, getRemoteTranslations } from './api.js';
   ·                                                      ──────────
 6 │ import type { TranslationRes } from './utils.js';
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
    ╭─[tools/cli/src/bin/dev-core.ts:9:46]
  8 │
  9 │ import { type BuildFlags, projectRoot } from '../config/index.js';
    ·                                              ────────────────────
 10 │ import { watchI18N } from '../util/i18n.js';
    ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
    ╭─[tools/cli/src/bin/dev-core.ts:10:27]
  9 │ import { type BuildFlags, projectRoot } from '../config/index.js';
 10 │ import { watchI18N } from '../util/i18n.js';
    ·                           ─────────────────
 11 │
    ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
   ╭─[tools/cli/src/util/i18n.ts:5:29]
 4 │
 5 │ import { projectRoot } from '../config/index.js';
   ·                             ────────────────────
 6 │
   ╰────

  ⚠ eslint-plugin-import(no-unresolved): Ensure imports point to a file/module that can be resolved
    ╭─[packages/frontend/electron/scripts/make-squirrel.ts:15:8]
 14 │   ROOT,
 15 │ } from './make-env.js';
    ·        ───────────────
 16 │
    ╰────

Boshen avatar Feb 28 '24 10:02 Boshen

This seems to be because, when typescript moduleResolution=nodenext, we have to add the .js suffix to the filename in the import statement

EYHN avatar Feb 28 '24 11:02 EYHN

In https://github.com/toeverything/blocksuite, We added .js extension in every import statement of ts file, can oxc support this?

EYHN avatar Feb 28 '24 11:02 EYHN