by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    CG-Tespy
    @CG-Tespy
    Because you usually do front-end JS?
    Frank Lemanschik
    @frank-dspeed
    no backend !!!
    i work on deno for example
    or i use graaljs
    and node also uses es6+
    the current node versions are working well
    Tomer Aberbach
    @TomerAberbach
    @frank-dspeed I don't have a repo, but I don't think the example you have let's me modify the entry points unless I'm misunderstanding something. I tried doing the following, but it doesn't work (I don't think the mutating of isEntry is actually persisted):
    import { findEntryPoints } from 'find-entry-points'
    import globby from 'globby'
    
    const autoEntry = () => ({
      name: `auto-entry`,
      async options (options) {
        const { input, ...rest } = options
    
        return {
          ...rest,
          input: globby.sync(input)
        }
      },
      async generateBundle (options, bundle) {
        const entryPoints = new Set((await findEntryPoints(this.getModuleIds(), {
          parseImports: ({ file: { path: moduleId } }) => {
            const { importedIds, dynamicallyImportedIds } = this.getModuleInfo(moduleId)
            return importedIds.concat(dynamicallyImportedIds)
          }
        })).map(([entryPoint]) => entryPoint))
    
        for (const assetOrChunk of Object.values(bundle)) {
          if (assetOrChunk.type === `chunk`) {
            const chunk = assetOrChunk
            chunk.isEntry = entryPoints.has(chunk.facadeModuleId)
          }
        }
      }
    })
    
    export default autoEntry
    Frank Lemanschik
    @frank-dspeed
    @TomerAberbach i came to the same conclusion but i found a little workaround :)
    we could create a virtual module that imports every JS file via the glob pattern
    and then we could in the generateBundle hook re emitFile the entrypoints
    and remove the none entrypoint version
    that is do able
    this way */.js would get imported by a virtual entrypoint that gets removed later
    so all are none entrypoints :)
    and when we do this.emitFile('chunk') they are entrypoints
    but i was thinking a lot about the algo and watched your good visual examples
    i am not sure if that is really detected able if something is entrypoint if it is circling imported
    Tomer Aberbach
    @TomerAberbach

    Would this.emitFile cause the files to get retransformed?

    For cyclic entry points you just have to choose one of them to get all of the files transitively imported (that's why I have .map(([entryPoint]) => entryPoint)) in the code example I sent). I'm thinking of emitting a warning for it though

    Frank Lemanschik
    @frank-dspeed
    this.emitFile will turn it into a additional entrypoint right
    it will get transformed and loaded and everything
    this.emitFile is equal to putting it into input
    Tomer Aberbach
    @TomerAberbach
    Gotcha, would that mean that duplicate work is being done? Like the same code get transformed in the same way twice?
    Frank Lemanschik
    @frank-dspeed
    maybe but i think most time the result will be diffrent
    as it now will get handled as entrypoint
    but it is a lot of overhead at all thats true
    overall i found out when your stuff would work it would be best to use it even before rollup runs
    Tomer Aberbach
    @TomerAberbach
    Hmmm, is there a way to invoke Rollup purely for the purpose of constructing the module graph? Like not to generate anything, just to create the graph
    Frank Lemanschik
    @frank-dspeed
    not at present we are working on that in a bigger context also for caching and incremental builds
    at present it is acorn https://github.com/acornjs/acorn
    which is parsing files
    so rollup is build around that
    and the graph gets build from loading the files
    so we need to know the entrypoint to parse for additional files
    and rollup is building not really a graph it is building a array of objects and each object has some additional information about where it gets imported and what it imports
    Tomer Aberbach
    @TomerAberbach
    It'd be really hacky, but I could run Rollup, save the module graph in the first hook where it's available, and then throw an error, catch it outside, use the saved graph to find the entry points (using my package) and then run Rollup again with the found entry points
    Frank Lemanschik
    @frank-dspeed
    i am not sure if there is any advantage rollup can not build the correct graph without knowing the entrypoint :)
    i think you could use glob + acorn directly
    and then supply that to rollup
    Tomer Aberbach
    @TomerAberbach
    I think I'll try that. Maybe I'll look to see how Rollup uses it internally to make sure I'm doing it the same way
    Frank Lemanschik
    @frank-dspeed
    you only need to look into acron the rollup algo will not help you
    you need a diffrent one you simply use it to parse the imports
    this for example adds dynamic import to it
    acron is a parser so it takes the text version of the *.js files
    and can return to you for example the import export stuff
    Tomer Aberbach
    @TomerAberbach
    Does Rollup use acorn-dynamic-import for dynamic imports?
    Frank Lemanschik
    @frank-dspeed
    i think we did own code for it the plugin is only some lines
    Tomer Aberbach
    @TomerAberbach
    Gotcha, well I'll see if I can make it work tomorrow! Thanks for the help
    Adi Sahar
    @adi518
    How do I resolve deps when using rollup in a monorepo package? I'm getting the dreaded default import not found error, and it seems because the package it looks for was hoisted for some reason to the root workspace node_modules.
    Frank Lemanschik
    @frank-dspeed
    i do not understand what your talking about adi sorry