Skip to content

Add API alias options#490

Closed
legendecas wants to merge 1 commit into
vercel:masterfrom
legendecas:alias
Closed

Add API alias options#490
legendecas wants to merge 1 commit into
vercel:masterfrom
legendecas:alias

Conversation

@legendecas
Copy link
Copy Markdown
Contributor

Exposing alias options allowing to map one module to another and bundle the mapped module into the final archive.

Rollup alternatives: https://github.com/rollup/plugins/tree/master/packages/alias

Related: #460

Comment thread src/index.js
if (Array.isArray(aliasMap))
alias.forEach(alias => aliasMap[alias[0]] = alias[1]);
else if (typeof alias === 'object')
Object.keys(alias).forEach(from => aliasMap[from] = alias[from]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Object.keys(alias).forEach(from => aliasMap[from] = alias[from]);
aliasMap = alias;

I think you can avoid iteration here an assign instead

Copy link
Copy Markdown
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

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

What is the use case for this? Should there be a CLI option too?

@styfle styfle closed this Mar 23, 2020
@morgs32
Copy link
Copy Markdown

morgs32 commented Jul 25, 2020

I'm interested in this - wondering if it would enable transpiling other packages in a yarn workspace/monorepo? For example:

// packages/package1.js

import utils form 'package2'

If the main in package2's package.json is es6 or typescript, could it still be transpiled if we alias'd to it with a relative path instead of referencing the same package via node_modules in a yarn workspace (which points to the directory via symlink)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants