Skip to content

Commit

Permalink
feat: add exportConditions config to esinstall (#1757)
Browse files Browse the repository at this point in the history
* feat: expose exportConditions to esinstall

* feat: separate lookup fields
  • Loading branch information
ryansolid authored Dec 11, 2020
1 parent c3ec984 commit 749a42d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
7 changes: 6 additions & 1 deletion esinstall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,23 @@ import {
} from './types';

interface InstallOptions {
cwd: string;
alias: Record<string, string>;
lockfile?: ImportMap;
logLevel: LoggerLevel;
logger: AbstractLogger;
verbose?: boolean;
dest: string;
env: EnvVarReplacements;
treeshake?: boolean;
polyfillNode: boolean;
sourceMap?: boolean | 'inline';
externalPackage: string[];
externalPackageEsm: string[];
packageLookupFields: string[];
packageExportLookupFields: string[];
namedExports: string[];
rollup: {
context?: string;
plugins?: RollupPlugin[];
dedupe?: string[];
};
Expand Down
2 changes: 1 addition & 1 deletion esinstall/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-inject": "^4.0.2",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-replace": "^2.3.3",
"cjs-module-lexer": "^1.0.0",
"es-module-lexer": "^0.3.24",
Expand Down
4 changes: 4 additions & 0 deletions esinstall/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ interface InstallOptions {
externalPackage: string[];
externalPackageEsm: string[];
packageLookupFields: string[];
packageExportLookupFields: string[];
namedExports: string[];
rollup: {
context?: string;
Expand All @@ -285,6 +286,7 @@ function setOptionDefaults(_options: PublicInstallOptions): InstallOptions {
externalPackageEsm: [],
polyfillNode: false,
packageLookupFields: [],
packageExportLookupFields: [],
env: {},
namedExports: [],
rollup: {
Expand Down Expand Up @@ -316,6 +318,7 @@ export async function install(
treeshake: isTreeshake,
polyfillNode,
packageLookupFields,
packageExportLookupFields
} = setOptionDefaults(_options);
const env = generateEnvObject(userEnv);

Expand Down Expand Up @@ -417,6 +420,7 @@ ${colors.dim(
// whether to prefer built-in modules (e.g. `fs`, `path`) or local ones with the same names
preferBuiltins: true, // Default: true
dedupe: userDefinedRollup.dedupe || [],
exportConditions: packageExportLookupFields
}),
rollupPluginJson({
preferConst: true,
Expand Down
14 changes: 13 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,18 @@
is-module "^1.0.0"
resolve "^1.17.0"

"@rollup/plugin-node-resolve@^11.0.0":
version "11.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.0.0.tgz#770458fb26691a686c5f29f37dded94832ffce59"
integrity sha512-8Hrmwjn1pLYjUxcv7U7IPP0qfnzEJWHyHE6CaZ8jbLM+8axaarJRB1jB6JgKTDp5gNga+TpsgX6F8iuvgOerKQ==
dependencies:
"@rollup/pluginutils" "^3.1.0"
"@types/resolve" "1.17.1"
builtin-modules "^3.1.0"
deepmerge "^4.2.2"
is-module "^1.0.0"
resolve "^1.19.0"

"@rollup/plugin-replace@^2.3.3":
version "2.3.4"
resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-2.3.4.tgz#7dd84c17755d62b509577f2db37eb524d7ca88ca"
Expand Down Expand Up @@ -12367,7 +12379,7 @@ resolve-url@^0.2.1:
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=

resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.8.1:
resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.19.0, resolve@^1.3.2, resolve@^1.8.1:
version "1.19.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c"
integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==
Expand Down

1 comment on commit 749a42d

@vercel
Copy link

@vercel vercel bot commented on 749a42d Dec 11, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.