def _rollup_module(self, module_name, modules):
        js_entrypoint = join(self.application_dir, module_name,
                             module_name + '.js')
        out = ''
        if self.use_rollup:
            rollup_process = subprocess.Popen(
                [devtools_paths.node_path(),
                 devtools_paths.rollup_path()] + ROLLUP_ARGS +
                ['--input', js_entrypoint],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE)
            out, error = rollup_process.communicate()
        else:
            out = read_file(js_entrypoint)
        write_file(join(self.output_dir, module_name, module_name + '.js'),
                   minify_js(out))

        legacyFileName = module_name + '-legacy.js'
        if legacyFileName in modules:
            write_file(
                join(self.output_dir, module_name, legacyFileName),
                minify_js(
                    read_file(
                        join(self.application_dir, module_name,
                             legacyFileName))))
    def _rollup_module(self, module_name, modules, skip_rollup):
        legacyFileName = module_name + '-legacy.js'
        if legacyFileName in modules:
            write_file(
                join(self.output_dir, module_name, legacyFileName),
                minify_js(
                    read_file(
                        join(self.application_dir, module_name,
                             legacyFileName))))

        # Temporary hack, as we use `devtools_entrypoint` for this module now
        # TODO(crbug.com/1101738): remove once all folders are migrated
        if skip_rollup:
            return

        js_entrypoint = join(self.application_dir, module_name,
                             module_name + '.js')
        out = ''
        if self.use_rollup:
            rollup_process = subprocess.Popen([
                devtools_paths.node_path(),
                devtools_paths.rollup_path(), '--config',
                join(FRONT_END_DIRECTORY, 'rollup.config.js'), '--input',
                js_entrypoint
            ],
                                              stdout=subprocess.PIPE,
                                              stderr=subprocess.PIPE)
            out, error = rollup_process.communicate()
            if rollup_process.returncode != 0:
                print(error)
                sys.exit(rollup_process.returncode)
        else:
            out = read_file(js_entrypoint)
        write_file(join(self.output_dir, module_name, module_name + '.js'),
                   minify_js(out))
Esempio n. 3
0
    def _rollup_module(self, module_name, modules):
        js_entrypoint = join(self.application_dir, module_name,
                             module_name + '.js')
        out = ''
        if self.use_rollup:
            rollup_process = subprocess.Popen([
                devtools_paths.node_path(),
                devtools_paths.rollup_path(), '--config',
                join(FRONT_END_DIRECTORY, 'rollup.config.js'), '--input',
                js_entrypoint, '--external', EXTERNAL_MODULE_LIST
            ],
                                              stdout=subprocess.PIPE,
                                              stderr=subprocess.PIPE)
            out, error = rollup_process.communicate()
            if rollup_process.returncode != 0:
                print(error)
                sys.exit(rollup_process.returncode)
        else:
            out = read_file(js_entrypoint)
        write_file(join(self.output_dir, module_name, module_name + '.js'),
                   minify_js(out))

        legacyFileName = module_name + '-legacy.js'
        if legacyFileName in modules:
            write_file(
                join(self.output_dir, module_name, legacyFileName),
                minify_js(
                    read_file(
                        join(self.application_dir, module_name,
                             legacyFileName))))
Esempio n. 4
0
def rollup(input_path, output_path, filename, max_size, rollup_plugin):
    target = join(input_path, filename)
    rollup_process = subprocess.Popen(
        [devtools_paths.node_path(),
         devtools_paths.rollup_path()] +
        ['--format', 'iife', '-n', 'InspectorOverlay'] + ['--input', target] +
        ['--plugin', rollup_plugin, '--plugin', 'terser'],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)
    out, error = rollup_process.communicate()
    if not out:
        raise Exception("rollup failed: " + error)
    check_size(filename, out, max_size)
    write_file(join(output_path, filename), out)
    def _rollup_worker(self, output):
        js_entrypoint = join(self.application_dir,
                             self.app_file('unbundled.js'))
        rollup_process = subprocess.Popen(
            [devtools_paths.node_path(),
             devtools_paths.rollup_path()] + ROLLUP_ARGS +
            ['--input', js_entrypoint],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        out, error = rollup_process.communicate()

        if rollup_process.returncode != 0:
            print('Error while running rollup:')
            print(error)
            sys.exit(1)

        output.write(minify_js(out))