node_modules/@angular/elements/schematics/ng-add/index.js
/** Adds the document-register-element.js to the polyfills file. */
Adds the document-register-element.js to the polyfills file.
Adds the document - register - element . js to the polyfills file .
function addPolyfill(options) {
        var _this = this;
        return function (host, context) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
            var projectName, workspace, project, buildTarget, polyfills, content, recorder;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        projectName = options.project;
                        if (!projectName) {
                            throw new schematics_1.SchematicsException('Option "project" is required.');
                        }
                        return [4 , workspace_1.getWorkspace(host)];
                    case 1:
                        workspace = _a.sent();
                        project = workspace.projects.get(projectName);
                        if (!project) {
                            throw new schematics_1.SchematicsException("Project " + projectName + " is not defined in this workspace.");
                        }
                        if (project.extensions['projectType'] !== 'application') {
                            throw new schematics_1.SchematicsException("@angular/elements requires a project type of \"application\" but " + projectName + " isn't.");
                        }
                        buildTarget = project.targets.get('build');
                        if (!buildTarget || !buildTarget.options) {
                            throw new schematics_1.SchematicsException("Cannot find 'options' for " + projectName + " build target.");
                        }
                        polyfills = buildTarget.options.polyfills;
                        if (typeof polyfills !== 'string') {
                            throw new schematics_1.SchematicsException("polyfills for " + projectName + " build target is not a string.");
                        }
                        content = host.read(polyfills).toString();
                        if (!content.includes('document-register-element')) {
                            recorder = host.beginUpdate(polyfills);
                            recorder.insertRight(content.length, "import 'document-register-element';\n");
                            host.commitUpdate(recorder);
                        }
                        context.logger.info('Added "document-register-element" to polyfills.');
                        return [2 ];
                }
            });
        }); };
    }
function addPolyfill ( options ) { var _this = this ; return function ( host , context ) { return tslib_1 . __awaiter ( _this , void 0 , void 0 , function ( ) { var projectName , workspace , project , buildTarget , polyfills , content , recorder ; return tslib_1 . __generator ( this , function ( _a ) { switch ( _a . label ) { case 0 : projectName = options . project ; if ( ! projectName ) { throw new schematics_1 . SchematicsException ( 'Option "project" is required.' ) ; } return [ 4 , workspace_1 . getWorkspace ( host ) ] ; case 1 : workspace = _a . sent ( ) ; project = workspace . projects . get ( projectName ) ; if ( ! project ) { throw new schematics_1 . SchematicsException ( "Project " + projectName + " is not defined in this workspace." ) ; } if ( project . extensions [ 'projectType' ] !== 'application' ) { throw new schematics_1 . SchematicsException ( "@angular/elements requires a project type of \"application\" but " + projectName + " isn't." ) ; } buildTarget = project . targets . get ( 'build' ) ; if ( ! buildTarget || ! buildTarget . options ) { throw new schematics_1 . SchematicsException ( "Cannot find 'options' for " + projectName + " build target." ) ; } polyfills = buildTarget . options . polyfills ; if ( typeof polyfills !== 'string' ) { throw new schematics_1 . SchematicsException ( "polyfills for " + projectName + " build target is not a string." ) ; } content = host . read ( polyfills ) . toString ( ) ; if ( ! content . includes ( 'document-register-element' ) ) { recorder = host . beginUpdate ( polyfills ) ; recorder . insertRight ( content . length , "import 'document-register-element';\n" ) ; host . commitUpdate ( recorder ) ; } context . logger . info ( 'Added "document-register-element" to polyfills.' ) ; return [ 2 ] ; } } ) ; } ) ; } ; }
Adds the document-register-element.js to the polyfills file.
Adds the document - register - element . js to the polyfills file .
/*yield*/ /*return*/