Plugin that links node modules using the Angular compiler CLI.
()
| 167 | |
| 168 | /** Plugin that links node modules using the Angular compiler CLI. */ |
| 169 | function createLinkerEsbuildPlugin() { |
| 170 | return { |
| 171 | name: 'ng-link-esbuild', |
| 172 | setup: build => { |
| 173 | build.onLoad({filter: /fesm2022/}, async args => { |
| 174 | const filePath = args.path; |
| 175 | const content = await fs.promises.readFile(filePath, 'utf8'); |
| 176 | const {code} = await babel.transformAsync(content, { |
| 177 | filename: filePath, |
| 178 | compact: false, |
| 179 | plugins: [['@angular/compiler-cli/linker/babel', {linkerJitMode: true}]], |
| 180 | }); |
| 181 | |
| 182 | return {contents: code}; |
| 183 | }); |
| 184 | }, |
| 185 | }; |
| 186 | } |
| 187 | |
| 188 | main().catch(e => { |
| 189 | console.error(e); |