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

[config] Fix getConfigFile dirname issue #67

Merged
merged 3 commits into from
Aug 20, 2023
Merged

[config] Fix getConfigFile dirname issue #67

merged 3 commits into from
Aug 20, 2023

Conversation

ninthsun91
Copy link
Contributor

Issue or reason for change

Description of changes

  • have been using babel-plugin-transform-import-meta in babel plugin.
  • this plugin converts import.meta into CJS compatible code.

before

  • babel.config.json
{
  "presets": [
    "@babel/preset-typescript"
  ],
  "plugins": [
    [
      "module-resolver",
      {
        "alias": {
          "src": "./gen"
        }
      }
    ],
    "module-extension-resolver",
    "babel-plugin-transform-import-meta"
  ]
}
  • getConfigFile.ts
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const __dirname = fileURLToPath(new URL('.', require('url').pathToFileURL(__filename).toString()));

after

  • babel.config.json
{
  "presets": [
    "@babel/preset-typescript"
  ],
  "plugins": [
    [
      "module-resolver",
      {
        "alias": {
          "src": "./gen"
        }
      }
    ],
    "module-extension-resolver"
  ]
}
  • getConfigFile.ts
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const __dirname = path.dirname(fileURLToPath(import.meta.url));

Related issues and links

- babel-plugin-transform-import-meta was converting import.meta.url to require('url') which is not supported in esm syntax
- new URL is not supported in esm
@ninthsun91 ninthsun91 added reviews: required Requires reviews config Project configuration labels Aug 19, 2023
@ninthsun91
Copy link
Contributor Author

  • 이거 머지되고나면 설정파일 읽어올때 에러나던거 해결됩니다.
  • 읽어오는 설정파일 이름 gitoverc.json에서 .gitoverc.json으로 변경했습니다.

Copy link
Contributor

@waveinyu waveinyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다. 고생 많으셨습니다👍🏻

@@ -11,7 +11,6 @@
}
}
],
"module-extension-resolver",
"babel-plugin-transform-import-meta"
"module-extension-resolver"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분이 문제였군요 고생하셨습니다

@ninthsun91 ninthsun91 merged commit f30960c into main Aug 20, 2023
@ninthsun91 ninthsun91 deleted the fix/babel branch August 20, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Project configuration reviews: required Requires reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error in getting dirname
3 participants