-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercompiler: linkerstate: has PR
Milestone
Description
🐞 bug report
Affected Package
@angular/compiler 11.2.10 and 12.0.0-next9
Description
When I try to compile umd.min.js file (from partial build of Library) with Angular linker (Babel plugin) I get following error:
Unsupported syntax, expected a boolean literal.
umd.js file compiles without any problem
🔬 Minimal Reproduction
For compilation I used following script:
const { transformSync } = require('@babel/core');
const fs = require("fs");
const path = require("path");
const args = process.argv.splice(2);
const fileName = args[0];
const { createEs2015LinkerPlugin } = require('@angular/compiler-cli/linker/babel');
function createNgtscLogger(reporter) {
return {
level: 1,
debug(...args) { },
info(...args) {
console.log('info', args.join());
},
warn(...args) {
console.log('warning', args.join());
},
error(...args) {
console.log('error', args.join());
},
};
}
var plugin = createEs2015LinkerPlugin({
logger: createNgtscLogger(undefined),
sourceMapping: false,
fileSystem: {
resolve: path.resolve,
exists: fs.existsSync,
dirname: path.dirname,
relative: path.relative,
readFile: fs.readFileSync,
},
});
function applyLinker(file, linkerPlugin) {
if (!file.fileName.endsWith('.js')) {
return file.source;
}
const result = transformSync(file.source, {
filename: file.fileName,
plugins: [linkerPlugin],
compact: false,
parserOpts: { sourceType: 'unambiguous' },
});
if (result === null) {
console.warn('Babel transform did not have output');
}
if (result.code == null) {
console.warn('Babel transform result does not have any code');
}
return result.code;
}
let originalFile = fs.readFileSync(fileName, 'utf-8');
fs.writeFileSync(fileName + '.original', originalFile);
let result = applyLinker({
fileName: fileName,
source: originalFile
}, plugin);
fs.writeFileSync(fileName, result);
🔥 Exception or Error
e.message = `${(_opts$filename = opts.filename) != null ? _opts$filename : "unknown"}: ${e.message}`;
^
TypeError: Cannot create property 'message' on string 'sample.umd.min.js: Unsupported syntax, expected a boolean literal.
🌍 Your Environment
Angular Version:
Angular CLI: 11.2.9
Node: 12.16.3
OS: win32 x64
Angular: 11.2.10
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1102.9
@angular-devkit/build-angular 0.1102.9
@angular-devkit/core 11.2.9
@angular-devkit/schematics 11.2.9
@angular/cli 11.2.9
@angular/material 11.2.9
@schematics/angular 11.2.9
@schematics/update 0.1102.9
ng-packagr 11.2.4
rxjs 6.6.7
typescript 4.1.5
klemenoslaj
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercompiler: linkerstate: has PR