Skip to content

Commit

Permalink
[Storage] Throw errors for unresolved imports in the browser (Azure#1…
Browse files Browse the repository at this point in the history
…3293)

As seen at Azure#13267 (comment), unresolved "crypto" module in the browser caused the angular app to break.
This could have been caught before if the build step with rollup had thrown an error instead of a warning for the unresolved imports in the browser. This PR attempts to throw an error instead of a warning for the unresolved imports.

Example
>  ![image](https://user-images.githubusercontent.com/10452642/105153986-e4ddec00-5abd-11eb-8b76-7b52c1b6cc6d.png)

Azure#13275 would fix the supposed rollup error (Azure#13294).

Also, we don't publish the browser bundle, but this rollup error from the build step would be capable of catching regressions before we publish the library.

@ljian3377 @jeremymeng @bterlson @xirzec @witemple-msft
  • Loading branch information
HarshaNalluru authored Feb 2, 2021
1 parent 0b902e5 commit 41c0645
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
7 changes: 6 additions & 1 deletion sdk/storage/storage-blob-changefeed/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ export function browserConfig(test = false) {
})
],
onwarn(warning, warn) {
if (warning.code === "CIRCULAR_DEPENDENCY") {
if (
warning.code === "CIRCULAR_DEPENDENCY" ||
warning.code === "UNRESOLVED_IMPORT"
// Unresolved imports in the browser may break apps with frameworks such as angular.
// Shim the modules with dummy src files for browser to avoid regressions.
) {
throw new Error(warning.message);
}
warn(warning);
Expand Down
7 changes: 6 additions & 1 deletion sdk/storage/storage-blob/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ export function browserConfig(test = false) {
})
],
onwarn(warning, warn) {
if (warning.code === "CIRCULAR_DEPENDENCY") {
if (
warning.code === "CIRCULAR_DEPENDENCY" ||
warning.code === "UNRESOLVED_IMPORT"
// Unresolved imports in the browser may break apps with frameworks such as angular.
// Shim the modules with dummy src files for browser to avoid regressions.
) {
throw new Error(warning.message);
}
warn(warning);
Expand Down
7 changes: 6 additions & 1 deletion sdk/storage/storage-file-datalake/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ export function browserConfig(test = false) {
})
],
onwarn(warning, warn) {
if (warning.code === "CIRCULAR_DEPENDENCY") {
if (
warning.code === "CIRCULAR_DEPENDENCY" ||
warning.code === "UNRESOLVED_IMPORT"
// Unresolved imports in the browser may break apps with frameworks such as angular.
// Shim the modules with dummy src files for browser to avoid regressions.
) {
throw new Error(warning.message);
}
warn(warning);
Expand Down
7 changes: 6 additions & 1 deletion sdk/storage/storage-file-share/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ export function browserConfig(test = false) {
})
],
onwarn(warning, warn) {
if (warning.code === "CIRCULAR_DEPENDENCY") {
if (
warning.code === "CIRCULAR_DEPENDENCY" ||
warning.code === "UNRESOLVED_IMPORT"
// Unresolved imports in the browser may break apps with frameworks such as angular.
// Shim the modules with dummy src files for browser to avoid regressions.
) {
throw new Error(warning.message);
}
warn(warning);
Expand Down
7 changes: 6 additions & 1 deletion sdk/storage/storage-internal-avro/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ export function browserConfig(test = false) {
})
],
onwarn(warning, warn) {
if (warning.code === "CIRCULAR_DEPENDENCY") {
if (
warning.code === "CIRCULAR_DEPENDENCY" ||
warning.code === "UNRESOLVED_IMPORT"
// Unresolved imports in the browser may break apps with frameworks such as angular.
// Shim the modules with dummy src files for browser to avoid regressions.
) {
throw new Error(warning.message);
}
warn(warning);
Expand Down
7 changes: 6 additions & 1 deletion sdk/storage/storage-queue/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ export function browserConfig(test = false) {
})
],
onwarn(warning, warn) {
if (warning.code === "CIRCULAR_DEPENDENCY") {
if (
warning.code === "CIRCULAR_DEPENDENCY" ||
warning.code === "UNRESOLVED_IMPORT"
// Unresolved imports in the browser may break apps with frameworks such as angular.
// Shim the modules with dummy src files for browser to avoid regressions.
) {
throw new Error(warning.message);
}
warn(warning);
Expand Down

0 comments on commit 41c0645

Please sign in to comment.