本文整理匯總了TypeScript中rollup-plugin-commonjs.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: require
// @ts-ignore
const pkg = require("./package.json")
const LIBRARY_NAME = "reactotron-mst"
const GLOBALS = ["ramda", "mobx-state-tree", "mobx"]
export default {
input: `build/es/${LIBRARY_NAME}.js`,
external: GLOBALS,
output: [
{
file: pkg.main,
name: camelCase(LIBRARY_NAME),
format: "umd",
sourcemap: true,
globals: GLOBALS,
},
{
file: pkg.module,
format: "es",
sourcemap: true,
globals: GLOBALS,
},
],
watch: {
include: "build/es/**",
},
plugins: [commonjs(), resolve(), sourceMaps(), filesize()],
}
示例2: require
import scss from 'rollup-plugin-scss';
const pkg = require('./package.json');
const libraryName = 'formulize';
export default {
input: `src/${libraryName}.ts`,
output: [
{ file: pkg.main, name: camelCase(libraryName), format: 'umd', sourcemap: true }
],
external: [],
watch: {
include: 'src/**',
},
plugins: [
scss({ output: `dist/${libraryName}.css` }),
json(),
typescript({
tsconfigOverride: {
compilerOptions: {
module: 'es2015'
}
},
useTsconfigDeclarationDir: true
}),
commonjs(),
resolve(),
sourceMaps(),
]
};
示例3: async
export default async (_: any, argv: any): Promise<Configuration> => {
const IS_PRODUCTION = argv.mode === 'production';
const CHANGELOG = await getMostRecentChangelogEntry();
// Clean out dist directory
await rimraf(path.join(__dirname, 'dist', '*'));
await Promise.all([
rollup({
input: 'citeproc',
plugins: [
resolve(),
commonjs(),
IS_PRODUCTION &&
(await import('rollup-plugin-terser')).terser(),
],
}),
]).then(([citeproc]) =>
Promise.all([
citeproc.write({
file: 'dist/vendor/citeproc.js',
format: 'iife',
name: 'CSL',
}),
]),
);
const plugins = new Set<Plugin>([
new MiniCssExtractPlugin(),
new CopyWebpackPlugin([
{
from: '**/*.{php,mo,pot}',
ignore: ['academic-bloggers-toolkit.php'],
},
{
from: '*.json',
transform(content) {
return JSON.stringify(JSON.parse(content.toString()));
},
},
{
from: path.resolve(__dirname, 'LICENSE'),
},
{
from: 'academic-bloggers-toolkit.php',
transform(content) {
return content.toString().replace(/{{VERSION}}/g, VERSION);
},
},
{
from: 'readme.txt',
transform(content) {
return content
.toString()
.replace(/{{VERSION}}/g, VERSION)
.replace(/{{CHANGELOG}}/g, CHANGELOG);
},
},
]),
new CheckerPlugin(),
]);
if (IS_PRODUCTION) {
plugins.add(new ProgressPlugin());
} else {
plugins.add(
new BrowserSyncPlugin({
proxy: 'localhost:8080',
open: false,
reloadDebounce: 2000,
port: 3005,
notify: false,
}),
);
}
const TS_BASE_CONFIG = {
silent: argv.json,
useCache: !IS_PRODUCTION,
cacheDirectory: path.resolve(
__dirname,
'node_modules/.cache/awesome-typescript-loader',
),
reportFiles: ['**/*.{ts,tsx}', '!**/__tests__/**'],
};
return {
devtool: IS_PRODUCTION ? 'source-map' : 'cheap-module-eval-source-map',
watchOptions: {
ignored: /(node_modules|__tests__)/,
},
context: path.resolve(__dirname, 'src'),
externals: {
'@wordpress/api-fetch': 'wp.apiFetch',
'@wordpress/block-editor': 'wp.blockEditor',
'@wordpress/blocks': 'wp.blocks',
'@wordpress/components': 'wp.components',
'@wordpress/compose': 'wp.compose',
'@wordpress/data': 'wp.data',
'@wordpress/dom-ready': 'wp.domReady',
//.........這裏部分代碼省略.........
示例4: SwRewriter
gulp.task('task:worker:basic:bundle', done => rollup
.rollup({
entry: 'tmp/esm/src/worker/builds/basic.js',
plugins: [
// TODO(alxhub): Switch to rxjs-es when export bug is fixed.
new SwRewriter(),
nodeResolve({jsnext: true, main: true}),
commonjs({
include: 'node_modules/**',
namedExports: {
'node_modules/jshashes/hashes.js': ['SHA1']
}
})
]
})
.then(bundle => bundle.write({
format: 'iife',
dest: 'tmp/es5/bundles/worker-basic.js',
})));
示例5: nodeResolve
gulp.task('task:app:bundle', done => rollup
.rollup({
entry: 'tmp/esm/src/index.js',
plugins: [
nodeResolve({jsnext: true, main: true}),
commonjs({
include: 'node_modules/**',
}),
],
external: [
'@angular/core',
]
})
.then(bundle => bundle.write({
format: 'umd',
moduleName: 'ng.appShell',
dest: 'tmp/es5/bundles/app-shell.umd.js',
globals: {
'@angular/core': 'ng.core',
},
})));
示例6:
import commonjs from 'rollup-plugin-commonjs';
// $ExpectType Plugin
commonjs();
// $ExpectType Plugin
commonjs({});
// $ExpectType Plugin
commonjs({
include: 'node_modules/**',
exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],
extensions: [ '.js', '.coffee' ],
ignoreGlobal: false,
sourceMap: false,
namedExports: { './module.js': ['foo', 'bar' ] },
ignore: [ 'conditional-runtime-dependency' ],
});
示例7: createRollupBundle
/** Creates a rollup bundle of a specified JavaScript file.*/
private async createRollupBundle(config: RollupBundleConfig) {
const bundleOptions = {
context: 'this',
external: Object.keys(rollupExternals),
input: config.entry,
onwarn: (message: string) => {
if (/but never used/.test(message)) {
return false;
}
console.warn(message);
},
plugins: [
rollupRemoveLicensesPlugin,
rollupNodeResolutionPlugin(),
rollupAlias(this.getResolvedSecondaryEntryPointImportPaths(config.dest))
]
};
const writeOptions = {
name: config.moduleName || 'ng.web',
amd: { id: config.importName },
globals: rollupGlobals,
file: config.dest,
format: config.format,
banner: buildConfig.licenseBanner,
sourcemap: false
};
bundleOptions.plugins.push(commonjs({
include: 'node_modules/**'
}));
// Only transpile es5 / umd packages
if (!config.es6) {
bundleOptions.plugins.push(babel({
include: 'node_modules/**'
}));
}
// For UMD bundles, we need to adjust the `external` bundle option in order to include
// all necessary code in the bundle.
if (config.format === 'umd') {
// bundleOptions.plugins.push(minify());
// For all UMD bundles, we want to exclude tslib from the `external` bundle option so that
// it is inlined into the bundle.
let external = Object.keys(rollupGlobals);
external.splice(external.indexOf('tslib'), 1);
// If each secondary entry-point is re-exported at the root, we want to exclude those
// secondary entry-points from the rollup globals because we want the UMD for the
// primary entry-point to include *all* of the sources for those entry-points.
if (this.buildPackage.exportsSecondaryEntryPointsAtRoot &&
config.moduleName === `ng.${this.buildPackage.name}`) {
const importRegex = new RegExp(`@angular-mdc/${this.buildPackage.name}/.+`);
external = external.filter(e => !importRegex.test(e));
}
bundleOptions.external = external;
}
return rollup.rollup(bundleOptions).then((bundle: any) => bundle.write(writeOptions));
}
示例8: babel
pkg.unpkg && { name: pkg.name, file: pkg.unpkg, format: 'umd' }
].filter(Boolean),
plugins: [
babel({
configFile: path.join(__dirname, 'babel.config.js'),
extensions: ['.ts', '.tsx', '.js']
}),
resolve({
extensions: ['.ts', '.tsx', '.js']
}),
commonjs({
namedExports: {
'@storybook/addon-actions': [
'action',
'ADDON_ID',
'PANEL_ID',
'EVENT_ID'
],
'@storybook/addons': ['makeDecorator'],
react: [
'createContext',
'createElement',
'Component',
'Fragment',
'forwardRef'
]
}
})
]
};
示例9: includePaths
treeshake: true,
plugins: [
includePaths({
include: {},
paths: [join(Config.TMP_DIR, 'app')],
external: [],
extensions: ['.js', '.json', '.html', '.ts']
}),
nodeResolve({
jsnext: true,
main: true,
module: true
}),
commonjs({
//See project.config.ts to extend
include: Config.ROLLUP_INCLUDE_DIR,
namedExports: Config.getRollupNamedExports()
})
]
};
export = (done: any) => {
rollup
.rollup(config)
.then((bundle: any) =>
bundle.generate({
format: 'iife',
sourcemap: Config.PRESERVE_SOURCE_MAPS
})
)
.then((result: any) => {
示例10: require
const pluginBabel = require('rollup-plugin-babel')
const pluginNodeResolve = require('rollup-plugin-node-resolve')
const pluginCommonJS = require('rollup-plugin-commonjs')
const pluginImage = require('rollup-plugin-url')
const pluginMarkdown = require('rollup-plugin-md')
const pluginTypescript = require('rollup-plugin-typescript')
const pluginReplace = require('rollup-plugin-replace')
const path = require('path')
export const plugins = [
pluginImage(),
pluginMarkdown(),
pluginNodeResolve(),
pluginCommonJS(),
pluginReplace({ 'process.env.NODE_ENV': '"production"' }),
pluginTypescript({
tsconfig: false,
experimentalDecorators: true,
module: 'es2015'
}),
pluginBabel({
presets: [
[
require.resolve('@babel/preset-env'),
{
modules: false,
targets: {
browsers: ['last 2 versions']
}
}
]