How to use the magic-string.Bundle function in magic-string

To help you get started, we’ve selected a few magic-string examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esperantojs / esperanto / dist / esperanto.js View on Github external
function combine(bundle) {
	bundle.body = new MagicString.Bundle({
		separator: '\n\n'
	});

	// give each module in the bundle a unique name
	populateModuleNames(bundle);

	// determine which specifiers are imported from
	// external modules
	populateExternalModuleImports(bundle);

	// determine which identifiers need to be replaced
	// inside this bundle
	populateIdentifierReplacements(bundle);

	bundle.exports = resolveExports(bundle);
github magento / baler / src / createBundleFromDeps.ts View on Github external
function createBundle(
    modules: { dep: string; file: MagicString; hasInvalidShim: boolean }[],
) {
    const bundle = new Bundle();
    const depsWithInvalidShims: string[] = [];

    bundle.prepend(
        `/* Generated by @magento/baler - ${new Date().toISOString()} */\n\n`,
    );

    for (const { dep, file, hasInvalidShim } of modules) {
        bundle.addSource({
            filename: `../${dep}.js`,
            content: file,
        });
        if (hasInvalidShim) depsWithInvalidShims.push(dep);
    }

    return { bundle, depsWithInvalidShims };
}
github VadimDez / ngx-img-fallback / node_modules / angular-cli / node_modules / rollup / src / Bundle.js View on Github external
render ( options = {} ) {
		const format = options.format || 'es6';

		// Determine export mode - 'default', 'named', 'none'
		const exportMode = getExportMode( this, options.exports );

		let magicString = new MagicString.Bundle({ separator: '\n\n' });
		let usedModules = [];

		this.orderedModules.forEach( module => {
			const source = module.render( format === 'es6' );
			if ( source.toString().length ) {
				magicString.addSource( source );
				usedModules.push( module );
			}
		});

		const intro = [ options.intro ]
			.concat(
				this.plugins.map( plugin => plugin.intro && plugin.intro() )
			)
			.filter( Boolean )
			.join( '\n\n' );
github rollup / rollup / src / Chunk.ts View on Github external
preRender(options: OutputOptions, inputBase: string) {
		timeStart('render modules', 3);

		const magicString = new MagicStringBundle({ separator: options.compact ? '' : '\n\n' });
		this.usedModules = [];
		this.indentString = options.compact ? '' : getIndentString(this.orderedModules, options);

		const n = options.compact ? '' : '\n';
		const _ = options.compact ? '' : ' ';

		const renderOptions: RenderOptions = {
			compact: options.compact as boolean,
			dynamicImportFunction: options.dynamicImportFunction as string,
			format: options.format as string,
			freeze: options.freeze !== false,
			indent: this.indentString,
			namespaceToStringTag: options.namespaceToStringTag === true,
			varOrConst: options.preferConst ? 'const' : 'var'
		};
github ghybs / zxingjs2 / build / build.js View on Github external
function bundleFiles(files, copyright) {
    var bundle = new MagicString.Bundle();

    for (var i = 0, len = files.length; i < len; i++) {
        bundle.addSource({
            filename: files[i],
            content: new MagicString( fs.readFileSync(files[i], 'utf8') + '\n\n' )
        });
    }

    bundle.prepend(
        copyright + "(function (window, document, undefined) {"
    ).append("})(window, document);");

    return bundle;
}
github ghybs / Leaflet.MarkerCluster.LayerSupport / build / build.js View on Github external
function bundleFiles(files, copyright) {
    var bundle = new MagicString.Bundle(),
        umdTemplate = require(__dirname + "/umd.template.js"),
        i = 0;

    for (; i < files.length; i += 1) {
        bundle.addSource({
            filename: files[i],
            content: new MagicString( fs.readFileSync(files[i], "utf8") + "\n\n" )
        });
    }

    bundle.prepend(
        copyright + umdTemplate.before
    ).append(umdTemplate.after);

    return bundle;
}
github ghybs / Leaflet.MarkerCluster.Freezable / build / build.js View on Github external
function bundleFiles(files, copyright) {
    var bundle = new MagicString.Bundle(),
        umdTemplate = require(__dirname + "/umd.template.js"),
        i = 0;

    for (; i < files.length; i += 1) {
        bundle.addSource({
            filename: files[i],
            content: new MagicString( fs.readFileSync(files[i], "utf8") + "\n\n" )
        });
    }

    bundle.prepend(
        copyright + umdTemplate.before
    ).append(umdTemplate.after);

    return bundle;
}
github ghybs / Leaflet.TileLayer.Fallback / build / build.js View on Github external
function bundleFiles(files, copyright) {
    var bundle = new MagicString.Bundle(),
        umdTemplate = require(__dirname + "/umd.template.js"),
        i = 0;

    for (; i < files.length; i += 1) {
        bundle.addSource({
            filename: files[i],
            content: new MagicString( fs.readFileSync(files[i], "utf8") + "\n\n" )
        });
    }

    bundle.prepend(
        copyright + umdTemplate.before
    ).append(umdTemplate.after);

    return bundle;
}
github unlight / gulp-cssimport / gulp-cssimport.js View on Github external
.then(function(results) {
                var iterator = function() { };
                if (vinyl.sourceMap) {
                    var bundle = new MagicString.Bundle();
                    iterator = function(file, result) {
                        bundle.addSource({
                            filename: result.importPath,
                            content: new MagicString(result.contents)
                        });
                    };
                }
                for (var i = 0; i < results.length; i++) {
                    var result = results[i];
                    var index = result.index;
                    var contents = result.contents;
                    file[index] = contents;
                    iterator(file, result);
                }
                vinyl.contents = new Buffer(file.join(""));
                if (vinyl.sourceMap) {

magic-string

Modify strings, generate sourcemaps

MIT
Latest version published 20 days ago

Package Health Score

89 / 100
Full package analysis