forked from dotnet/aspnetcore
-
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.
[Blazor] Update other packages to bundle with rollup (dotnet#53117)
* Updated all other "JS" packages in compoents to bundle with rollup instead of webpack. * CustomElements uses "ES" format as its a JSInitializer. * AuthenticationService for msal and webassembly auth use "iife" format (immediately invoked function expression) since that's what's backwards compatible with the way they were imported.
- Loading branch information
Showing
13 changed files
with
289 additions
and
387 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import path from 'path'; | ||
import typescript from '@rollup/plugin-typescript'; | ||
import terser from '@rollup/plugin-terser'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import replace from '@rollup/plugin-replace'; | ||
import filesize from 'rollup-plugin-filesize'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
console.log(__dirname); | ||
|
||
export default ({ environment }) => { | ||
|
||
var inputOutputMap = { | ||
'Microsoft.AspNetCore.Components.CustomElements.lib.module': './BlazorCustomElements.ts', | ||
}; | ||
|
||
/** | ||
* @type {import('rollup').RollupOptions} | ||
*/ | ||
const baseConfig = { | ||
output: { | ||
dir: path.join(__dirname, '/dist', environment === 'development' ? '/Debug' : '/Release'), | ||
format: 'es', | ||
sourcemap: true, | ||
entryFileNames: '[name].js', | ||
sourcemap: environment === 'development' ? 'inline' : false, | ||
}, | ||
plugins: [ | ||
resolve(), | ||
commonjs(), | ||
typescript({ | ||
tsconfig: path.join(__dirname, 'tsconfig.json') | ||
}), | ||
replace({ | ||
'process.env.NODE_DEBUG': 'false', | ||
'Platform.isNode': 'false', | ||
preventAssignment: true | ||
}), | ||
terser({ | ||
compress: { | ||
passes: 3 | ||
}, | ||
mangle: true, | ||
module: false, | ||
format: { | ||
ecma: 2020 | ||
}, | ||
keep_classnames: false, | ||
keep_fnames: false, | ||
toplevel: true | ||
}) | ||
, | ||
environment !== 'development' && filesize({ showMinifiedSize: true, showGzippedSize: true, showBrotliSize: true }) | ||
], | ||
treeshake: 'smallest', | ||
logLevel: 'silent' | ||
}; | ||
|
||
return Object.entries(inputOutputMap).map(([output, input]) => { | ||
const config = { | ||
...baseConfig, | ||
output: { | ||
...baseConfig.output, | ||
}, | ||
input: { [output]: input } | ||
}; | ||
|
||
return config; | ||
}); | ||
}; |
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,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2019", | ||
"module": "commonjs", | ||
"lib": [ "DOM", "ES2019" ], | ||
"sourceMap": true, | ||
"target": "ES2022", | ||
"module": "ESNext", | ||
"lib": [ "DOM", "ES2022" ], | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true | ||
} | ||
} |
Oops, something went wrong.