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

How add extension for esm output ? #883

Closed
ZababurinSergei opened this issue May 2, 2024 · 2 comments
Closed

How add extension for esm output ? #883

ZababurinSergei opened this issue May 2, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@ZababurinSergei
Copy link

Hi !

The project has a ts to esm module conversion.

       "build": "gulp --gulpfile ./build/gulpfile.js",

tsConfig

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "lib": ["es5", "es6", "es7", "es2017", "dom", "ESNext"],
        "sourceMap": true,
        "allowJs": true,
        "jsx": "react",
        "moduleResolution": "node",
        "baseUrl": "./",
        "strict": true /* Enable all strict type-checking options. */,
        "forceConsistentCasingInFileNames": true,
        "noImplicitReturns": true,
        "noImplicitThis": true,
        "noImplicitAny": false,
        "strictNullChecks": true,
        "skipLibCheck": true,
        "suppressImplicitAnyIndexErrors": true,
        "noUnusedLocals": true,
        "noUnusedParameters": false,
        "declaration": true,
        "allowSyntheticDefaultImports": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "resolveJsonModule": true,
        "downlevelIteration": true,
        "paths": {
            "mo": ["./src/index.ts"],
            "mo/*": ["./src/*"],
            "@stories": ["./stories/*"],
            "@test/*": ["./test/*"]
        },
        "typeRoots": ["node", "node_modules/@types", "src/typings"]
    },
    "exclude": ["node_modules", "build", "scripts"]
}

But the output files do not have an extension and cannot be included in a project from esm directory.

import { Menu } from './../../components/menu';
import { mergeFunctions } from './../../common/utils';

How to add or can you add an option to tsConfig so that the output files have the extension ?

What would it be like this

import { Menu } from './../../components/menu/index.js';
import { mergeFunctions } from './../../common/utils/index.js';
@ZababurinSergei ZababurinSergei added the help wanted Extra attention is needed label May 2, 2024
@mortalYoung
Copy link
Collaborator

I don't know why you want the extension for output files? In general, you start your application with Webpack or Vite or otherelse will works fine.

@ZababurinSergei
Copy link
Author

This is a very big minus.
It is impossible to run your application without Webpack or Vite or otherelse.

A very large number of modules already take this into account when assembling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants