Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle namespaces that reexport themselves (#3077)
* Create test * Separate namespace initialisation from creation to prevent an infinite recursion * Throw for unexpected warnings in form tests This should also reduce test noise a lot * Update dependencies and fix vulnerability * Add test that guesses variable names to improve coverage again * Test that warnings can be cast to string * Retrigger CI
- Loading branch information
1 parent
a7e5ff2
commit 2c93e33
Showing
84 changed files
with
975 additions
and
467 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
test/form/samples/builtin-prototypes/object-expression/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
description: 'Tree-shake known object prototype functions' | ||
description: 'Tree-shake known object prototype functions', | ||
expectedWarnings: ['EMPTY_BUNDLE'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
module.exports = { | ||
description: 'compact output with compact: true', | ||
expectedWarnings: ['CIRCULAR_DEPENDENCY'], | ||
options: { | ||
external: ['external'], | ||
output: { | ||
name: 'foo', | ||
compact: true, | ||
namespaceToStringTag: true | ||
namespaceToStringTag: true, | ||
globals: { | ||
external: 'x' | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
module.exports = { | ||
description: 'ensures bundle imports are deconflicted (#659)', | ||
options: { | ||
external: ['foo', 'bar'] | ||
external: ['foo', 'bar'], | ||
output: { | ||
globals: { | ||
bar: 'bar', | ||
foo: 'foo' | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
test/form/samples/deprecated/prune-pure-unused-import-array/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
module.exports = { | ||
description: 'prunes pure unused external imports ([#1352])', | ||
options: { | ||
strictDeprecations: false, | ||
external: ['external', 'other'], | ||
treeshake: { pureExternalModules: ['external'] } | ||
}, | ||
description: 'prunes pure unused external imports ([#1352])' | ||
treeshake: { pureExternalModules: ['external'] }, | ||
output: { | ||
globals: { other: 'other' } | ||
} | ||
} | ||
}; |
10 changes: 7 additions & 3 deletions
10
test/form/samples/deprecated/prune-pure-unused-import-function/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
module.exports = { | ||
description: 'prunes pure unused external imports ([#1352])', | ||
expectedWarnings: ['EMPTY_BUNDLE'], | ||
options: { | ||
strictDeprecations: false, | ||
external: ['external', 'other'], | ||
treeshake: { pureExternalModules: id => id === 'external' } | ||
}, | ||
description: 'prunes pure unused external imports ([#1352])' | ||
treeshake: { pureExternalModules: id => id === 'external' }, | ||
output: { | ||
globals: { other: 'other' } | ||
} | ||
} | ||
}; |
5 changes: 3 additions & 2 deletions
5
test/form/samples/deprecated/prune-pure-unused-import/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
module.exports = { | ||
description: 'prunes pure unused external imports ([#1352])', | ||
expectedWarnings: ['EMPTY_BUNDLE'], | ||
options: { | ||
strictDeprecations: false, | ||
external: ['external', 'other'], | ||
treeshake: { pureExternalModules: true } | ||
}, | ||
description: 'prunes pure unused external imports ([#1352])' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
test/form/samples/deprecated/transform-bundle-plugin/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
module.exports = { | ||
description: 'external `export *` must not interfere with internal exports', | ||
options: { | ||
output: { name: 'exposedInternals' }, | ||
output: { | ||
globals: { external: 'external' }, | ||
name: 'exposedInternals' | ||
}, | ||
external: ['external'] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ var myBundle = (function (exports, a, Test$1) { | |
|
||
return exports; | ||
|
||
}({}, a, Test$1)); | ||
}({}, a, b)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
module.exports = { | ||
description: 'handles external aliased named imports that shadow another name', | ||
options: { | ||
external: ['acorn'] | ||
external: ['acorn'], | ||
output: { | ||
globals: { acorn: 'acorn' } | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
module.exports = { | ||
description: 'prefixes global names with `global.` when creating UMD bundle (#57)', | ||
expectedWarnings: ['UNUSED_EXTERNAL_IMPORT'], | ||
options: { | ||
external: ['factory', 'baz', 'shipping-port', 'alphabet'] | ||
external: ['factory', 'baz', 'shipping-port', 'alphabet'], | ||
output: { | ||
globals: { | ||
alphabet: 'alphabet', | ||
baz: 'baz', | ||
factory: 'factory', | ||
'shipping-port': 'containers' | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
module.exports = { | ||
description: 'Correctly handles external namespace tracing with both namespace and named exports', | ||
options: { | ||
external: ['foo'] | ||
external: ['foo'], | ||
output: { | ||
globals: { foo: 'foo' } | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
description: 'guesses global names if necessary', | ||
expectedWarnings: ['MISSING_GLOBAL_NAME'], | ||
options: { | ||
external: [ | ||
'unchanged', | ||
'changed', | ||
'special-character', | ||
'with/slash', | ||
resolve(__dirname, 'relative.js') | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define(['unchanged', 'changed', 'special-character', 'with/slash', './relative'], function (unchanged, changedName, specialCharacter, slash, relative_js) { 'use strict'; | ||
|
||
changedName = changedName && changedName.hasOwnProperty('default') ? changedName['default'] : changedName; | ||
|
||
console.log(unchanged.foo, changedName, specialCharacter.bar, slash.baz, relative_js.quux); | ||
|
||
}); |
Oops, something went wrong.