Last active
February 25, 2019 11:02
-
-
Save p3x-robot/e12ed76acb7033638b4179149546bb73 to your computer and use it in GitHub Desktop.
⛮ How to disable the remove Angular decorators @ngtools/webpack mess
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const cwd = process.cwd(); | |
const hackPath = `${cwd}/node_modules/@ngtools/webpack/src` | |
const hackFileName = `${hackPath}/angular_compiler_plugin.js` | |
const hackFileNameHacked = `${hackFileName}.hacked` | |
const log = '@ngtool/webpack angular decorators remove' | |
const hack = () => { | |
if (!fs.existsSync(hackFileNameHacked)) { | |
const problemCode = fs.readFileSync(hackFileName).toString('utf-8').split('\n'); | |
for(let index in problemCode) { | |
let line = problemCode[index]; | |
if (line.includes('removeDecorators')) { | |
if (!line.startsWith('//')) { | |
line = '//' + line; | |
problemCode[index] = line; | |
} | |
break; | |
} | |
} | |
const generatedHack = problemCode.join('\n'); | |
fs.writeFileSync(hackFileName, generatedHack) | |
fs.writeFile(hackFileNameHacked, log, function(err) { | |
if(err) { | |
throw err; | |
} | |
console.log(`${log} hack is cached`) | |
}); | |
console.log(`${log} is commented now`) | |
} else { | |
console.log(`${log} hack is cached`) | |
} | |
} | |
module.exports.hack = hack; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (options.AOT ) { | |
require('./hack-remove-decorators').hack(); | |
// it is important so that you hack it before you load the AngularCompilerPlugin | |
const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin; | |
plugins.push( | |
new AngularCompilerPlugin({ | |
tsConfigPath: root('./tsconfig.aot.json'), | |
entryModule: root('/module#Module'), | |
// skipCodeGeneration: true, | |
}) | |
) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where do i edit/put these fields? In @ngtools/webpack/src?