Coder Social home page Coder Social logo

Comments (8)

aelbore avatar aelbore commented on May 18, 2024

@ws456999 can you try this?

foo/index.tsx

export default class Foo {
  render() {
    return <div className="hehe">hello there!!!</div>
  }
}

index.js

import Foo from './foo/index'
console.log(Foo)

from rollup-plugin-esbuild.

ws456999 avatar ws456999 commented on May 18, 2024

@aelbore

foo/index.tsx

export default class Foo {
  render() {
    return <div className="hehe">hello there!!!</div>
  }
}

index.js

import Foo from './foo'
console.log(Foo)

works in rollup with rollup-plugin-typescript

my project have too much such case,
Locate modules using the Node resolution algorithm in webpack,how can i use same rule with some config or plugins?

from rollup-plugin-esbuild.

aelbore avatar aelbore commented on May 18, 2024

@ws456999 the thing is if you have foo/index.tsx and foo.tsx exist

from rollup-plugin-esbuild.

ws456999 avatar ws456999 commented on May 18, 2024

@aelbore It's two question,

  1. esbuild don't resolve module like Node resolution algorithm;

  2. the priority of location modules

I only care about the first question,Do you have any ideas?

from rollup-plugin-esbuild.

aelbore avatar aelbore commented on May 18, 2024

@aelbore
not sure if this is work around or this is the fixed
if foo.tsx exist load foo.tsx even if foo/index.tsx exist
else load the foo/index.tsx

and yes esbuild doesnt resolve like Node resolution

  const coreModule = (resolved: string) => {
    if (existsSync(resolved) && statSync(resolved).isDirectory()) {
      for (const loader of loaders) {
        const file = join(resolved, `index.${loader}`)
        if (existsSync(file)) {
          return file
        }
      }
    }
    return null
  }

  const loadFile = (resolved: string) => {
    for (const loader of loaders) {
      const file = `${resolved}.${loader}`
      if (existsSync(file)) {
        return file
      }
    }
    return null
  }

        let file = loadFile(resolved)
        if (file) return file
        if (!file) {
          file = coreModule(resolved)
          if (file) return file
        }

from rollup-plugin-esbuild.

ws456999 avatar ws456999 commented on May 18, 2024

@aelbore
it works for me! thanks a lot.

from rollup-plugin-esbuild.

ws456999 avatar ws456999 commented on May 18, 2024

looking forward to your next version

from rollup-plugin-esbuild.

aelbore avatar aelbore commented on May 18, 2024

looking forward to your next version
@ws456999
#5

from rollup-plugin-esbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.