Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use different globals for file accesses
- Loading branch information
1 parent
39ee6f8
commit 89a3024
Showing
20 changed files
with
138 additions
and
12 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
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
23 changes: 23 additions & 0 deletions
23
test/form/samples/asset-emission-tree-shaken-access/_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,23 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
description: 'does not include format globals when tree-shaking an asset access', | ||
options: { | ||
plugins: { | ||
resolveId(id, importee) { | ||
if (id.endsWith('.svg')) { | ||
return path.resolve(path.dirname(importee), id); | ||
} | ||
}, | ||
load(id) { | ||
if (id.endsWith('.svg')) { | ||
return `export default import.meta.ROLLUP_ASSET_URL_${this.emitAsset( | ||
path.basename(id), | ||
fs.readFileSync(id) | ||
)};`; | ||
} | ||
} | ||
} | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/form/samples/asset-emission-tree-shaken-access/_expected/amd.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,5 @@ | ||
define(function () { 'use strict'; | ||
|
||
console.log('main'); | ||
|
||
}); |
3 changes: 3 additions & 0 deletions
3
...rm/samples/asset-emission-tree-shaken-access/_expected/assets/logo-25253976.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
test/form/samples/asset-emission-tree-shaken-access/_expected/cjs.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,3 @@ | ||
'use strict'; | ||
|
||
console.log('main'); |
1 change: 1 addition & 0 deletions
1
test/form/samples/asset-emission-tree-shaken-access/_expected/es.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 @@ | ||
console.log('main'); |
6 changes: 6 additions & 0 deletions
6
test/form/samples/asset-emission-tree-shaken-access/_expected/iife.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,6 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
console.log('main'); | ||
|
||
}()); |
10 changes: 10 additions & 0 deletions
10
test/form/samples/asset-emission-tree-shaken-access/_expected/system.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,10 @@ | ||
System.register([], function () { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
console.log('main'); | ||
|
||
} | ||
}; | ||
}); |
8 changes: 8 additions & 0 deletions
8
test/form/samples/asset-emission-tree-shaken-access/_expected/umd.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 @@ | ||
(function (factory) { | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
factory(); | ||
}(function () { 'use strict'; | ||
|
||
console.log('main'); | ||
|
||
})); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 @@ | ||
import logo from './logo.svg'; | ||
|
||
if (false) { | ||
console.log(logo); | ||
} | ||
console.log('main'); |
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,3 @@ | ||
module.exports = { | ||
description: 'also does not include format globals when tree-shaking import meta' | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/form/samples/treeshake-import-meta-props/_expected/amd.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,5 @@ | ||
define(function () { 'use strict'; | ||
|
||
console.log('main'); | ||
|
||
}); |
3 changes: 3 additions & 0 deletions
3
test/form/samples/treeshake-import-meta-props/_expected/cjs.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,3 @@ | ||
'use strict'; | ||
|
||
console.log('main'); |
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 @@ | ||
console.log('main'); |
6 changes: 6 additions & 0 deletions
6
test/form/samples/treeshake-import-meta-props/_expected/iife.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,6 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
console.log('main'); | ||
|
||
}()); |
10 changes: 10 additions & 0 deletions
10
test/form/samples/treeshake-import-meta-props/_expected/system.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,10 @@ | ||
System.register([], function () { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
console.log('main'); | ||
|
||
} | ||
}; | ||
}); |
8 changes: 8 additions & 0 deletions
8
test/form/samples/treeshake-import-meta-props/_expected/umd.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 @@ | ||
(function (factory) { | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
factory(); | ||
}(function () { 'use strict'; | ||
|
||
console.log('main'); | ||
|
||
})); |
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,4 @@ | ||
const removed1 = import.meta; | ||
const removed2 = import.meta.url; | ||
const removed3 = import.meta.unknown; | ||
console.log('main'); |