Skip to content

Commit 41c0645

Browse files
[Storage] Throw errors for unresolved imports in the browser (Azure#13293)
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
1 parent 0b902e5 commit 41c0645

File tree

6 files changed

+36
-6
lines changed

6 files changed

+36
-6
lines changed

sdk/storage/storage-blob-changefeed/rollup.base.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ export function browserConfig(test = false) {
151151
})
152152
],
153153
onwarn(warning, warn) {
154-
if (warning.code === "CIRCULAR_DEPENDENCY") {
154+
if (
155+
warning.code === "CIRCULAR_DEPENDENCY" ||
156+
warning.code === "UNRESOLVED_IMPORT"
157+
// Unresolved imports in the browser may break apps with frameworks such as angular.
158+
// Shim the modules with dummy src files for browser to avoid regressions.
159+
) {
155160
throw new Error(warning.message);
156161
}
157162
warn(warning);

sdk/storage/storage-blob/rollup.base.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ export function browserConfig(test = false) {
151151
})
152152
],
153153
onwarn(warning, warn) {
154-
if (warning.code === "CIRCULAR_DEPENDENCY") {
154+
if (
155+
warning.code === "CIRCULAR_DEPENDENCY" ||
156+
warning.code === "UNRESOLVED_IMPORT"
157+
// Unresolved imports in the browser may break apps with frameworks such as angular.
158+
// Shim the modules with dummy src files for browser to avoid regressions.
159+
) {
155160
throw new Error(warning.message);
156161
}
157162
warn(warning);

sdk/storage/storage-file-datalake/rollup.base.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ export function browserConfig(test = false) {
164164
})
165165
],
166166
onwarn(warning, warn) {
167-
if (warning.code === "CIRCULAR_DEPENDENCY") {
167+
if (
168+
warning.code === "CIRCULAR_DEPENDENCY" ||
169+
warning.code === "UNRESOLVED_IMPORT"
170+
// Unresolved imports in the browser may break apps with frameworks such as angular.
171+
// Shim the modules with dummy src files for browser to avoid regressions.
172+
) {
168173
throw new Error(warning.message);
169174
}
170175
warn(warning);

sdk/storage/storage-file-share/rollup.base.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ export function browserConfig(test = false) {
148148
})
149149
],
150150
onwarn(warning, warn) {
151-
if (warning.code === "CIRCULAR_DEPENDENCY") {
151+
if (
152+
warning.code === "CIRCULAR_DEPENDENCY" ||
153+
warning.code === "UNRESOLVED_IMPORT"
154+
// Unresolved imports in the browser may break apps with frameworks such as angular.
155+
// Shim the modules with dummy src files for browser to avoid regressions.
156+
) {
152157
throw new Error(warning.message);
153158
}
154159
warn(warning);

sdk/storage/storage-internal-avro/rollup.base.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ export function browserConfig(test = false) {
151151
})
152152
],
153153
onwarn(warning, warn) {
154-
if (warning.code === "CIRCULAR_DEPENDENCY") {
154+
if (
155+
warning.code === "CIRCULAR_DEPENDENCY" ||
156+
warning.code === "UNRESOLVED_IMPORT"
157+
// Unresolved imports in the browser may break apps with frameworks such as angular.
158+
// Shim the modules with dummy src files for browser to avoid regressions.
159+
) {
155160
throw new Error(warning.message);
156161
}
157162
warn(warning);

sdk/storage/storage-queue/rollup.base.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ export function browserConfig(test = false) {
120120
})
121121
],
122122
onwarn(warning, warn) {
123-
if (warning.code === "CIRCULAR_DEPENDENCY") {
123+
if (
124+
warning.code === "CIRCULAR_DEPENDENCY" ||
125+
warning.code === "UNRESOLVED_IMPORT"
126+
// Unresolved imports in the browser may break apps with frameworks such as angular.
127+
// Shim the modules with dummy src files for browser to avoid regressions.
128+
) {
124129
throw new Error(warning.message);
125130
}
126131
warn(warning);

0 commit comments

Comments
 (0)