forked from rollup/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6e3730
commit bf71e00
Showing
6 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
packages/commonjs/test/fixtures/function/es6-export-with-global-sniffing/_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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const nodeResolve = require('@rollup/plugin-node-resolve'); | ||
|
||
module.exports = { | ||
options: { | ||
plugins: [nodeResolve()] | ||
}, | ||
pluginOptions: {} | ||
}; |
7 changes: 7 additions & 0 deletions
7
packages/commonjs/test/fixtures/function/es6-export-with-global-sniffing/main.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 @@ | ||
// this test makes sure that "submodule" is not wrapped in commonjs | ||
// helper due to its use of "typeof module", given that "submodule" has es6 exports. | ||
// any attempt to wrap it in a function will just fail as it's invalid syntax. | ||
|
||
import getGlobalPollution from './submodule.js'; | ||
|
||
t.is(getGlobalPollution(), global.pollution); |
19 changes: 19 additions & 0 deletions
19
packages/commonjs/test/fixtures/function/es6-export-with-global-sniffing/submodule.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,19 @@ | ||
let root; | ||
|
||
if (typeof self !== 'undefined') { | ||
root = self; | ||
} else if (typeof window !== 'undefined') { | ||
root = window; | ||
} else if (typeof global !== 'undefined') { | ||
root = global; | ||
} else if (typeof module !== 'undefined') { | ||
root = module; | ||
} else { | ||
root = Function('return this')(); // eslint-disable-line no-new-func | ||
} | ||
|
||
root.pollution = 'foo'; | ||
|
||
const getGlobalPollution = () => 'foo'; | ||
|
||
export default getGlobalPollution; |
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
Binary file not shown.