diff --git a/tools/ng_rollup_bundle/rollup.config.js b/tools/ng_rollup_bundle/rollup.config.js index daf90067b6..d7e1b05fe1 100644 --- a/tools/ng_rollup_bundle/rollup.config.js +++ b/tools/ng_rollup_bundle/rollup.config.js @@ -65,16 +65,19 @@ function resolveBazel( return undefined; } } - // Attempt to resovle first as specified, then in the following order - // {importee}.mjs, {importee}/index.mjs, {importee}.js, {importee}/index.js. + // Attempt in the following order {importee}.mjs, {importee}/index.mjs, + // {importee}, {importee}.js, {importee}/index.js. If an .mjs file is + // available it should be resolved as rollup cannot handle the .js files + // generated by ts_library as they are not esm. When rolling up esm5 files + // these are re-rooted so it is not an issue. // TODO(gregmagolan): clean this up in the future as the .mjs es2015 outputs // along side the .js es5 outputs from ts_library creates this unusual situation for // which we can't rely on standard node module resolution to do the right thing. // In the future ts_library (or equivalent) should only produce a single flavor of // output and ng_rollup_bundle should also just use the use the vanilla rollup_bundle // rule without the need for a custom bazel resolver. - return tryImportee(importee) || tryImportee(`${importee}.mjs`) || - tryImportee(`${importee}/index.mjs`) || tryImportee(`${importee}.js`) || + return tryImportee(`${importee}.mjs`) || tryImportee(`${importee}/index.mjs`) || + tryImportee(importee) || tryImportee(`${importee}.js`) || tryImportee(`${importee}/index.js`); }