Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AngularJS 1.5 pattern escape problem #1548

Open
jamesbcn opened this issue Nov 18, 2022 · 6 comments
Open

AngularJS 1.5 pattern escape problem #1548

jamesbcn opened this issue Nov 18, 2022 · 6 comments

Comments

@jamesbcn
Copy link

jamesbcn commented Nov 18, 2022

Bug report

Webpack version: 5.75.0
TS-Loader version: 9.4.1
Please tell us about your environment: Windows 10

Current behavior:
I am migrating AngularJS, and some inputs have ng-pattern attribute. TS-Loader removes backslashes in regex inside this attribute and because of this regex is not valid.
In my code I have ng-pattern="/^\+[\d]{7,15}$/" and output is ng-pattern="/^\+[\d]{7,15}$/"

The same problem was reported and fixed in HTML-Loader here

Expected/desired behavior:
Please add regex processing.

tsconfig.json
{ "compilerOptions": { "baseUrl": "", "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es6", "dom"], "mapRoot": "./", "module": "es6", "moduleResolution": "node", "outDir": "../dist/out-tsc", "sourceMap": true, "target": "es5", "typeRoots": [ "./node_modules/@types" ] } }

webpack.config.js
module.exports = { entry: "./app/main.ts", output: { filename: "src/dist/bundle.js" }, resolve: { // Add '.ts' and '.tsx' as a resolvable extension. extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"] }, module: { rules: [ // all files with a '.ts' or '.tsx' extension will be handled by 'ts-loader' { test: /\.tsx?$/, loader: "ts-loader" } ] }, optimization:{ minimize: false } };

@johnnyreilly
Copy link
Member

ts-loader handles TypeScript - it doesn't handle templates; I'm not sure where you'd do this, but probably not in ts-loader

@jamesbcn
Copy link
Author

OK. I have reported it to Webpack: https://github.com/webpack/webpack/issues/16488

Thanks.

@jamesbcn
Copy link
Author

They are saying the same. It is not their issue but a loader issue.

Ts-loader is the only loader I am using and the HTML is inline within the .ts files...

@johnnyreilly
Copy link
Member

ts-loader doesn't directly process TS files - that is handled by TypeScript itself. I wonder if you can manually escape your regexes to get around this issue

@johnnyreilly
Copy link
Member

Given angular js is end of life you may want to think about migration away from it https://en.m.wikipedia.org/wiki/AngularJS

@jamesbcn
Copy link
Author

Manually escaping should work - it's just a lot of work.

And yeah, I'm in the process of migrating. First step was to switch to Typescript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants