Skip to content

Get filename in transform callback #58

@ayush000

Description

@ayush000

Is it possible to get file path of the input file being transformed inside transform callback? For my use case, I need to pass the path to babel's transformSync method.

new MergeIntoSingleFilePlugin({
  files: {
   "output.js": ["inputFile1", "inputFile2", "inputFile3"]
  },
  transform: {
    // Filepath is currently not passed to transform callback. This is just an example to demonstrate use case
    "output.js": (code, filePath) => {
      babel.transformSync(code, {filename: filePath});
    }
  }
})

For now, it is working for me just by specifying some random filePath, since babel is just using filePath for matching it against overrides. But I was wondering if others might have a similar usecase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions