TypeStrong / TypeStrong/ts-loader

AngularJS 1.5 pattern escape problem

Open
#1,548 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.5k
Forks
439
Avg merge
17h 17m
Merged PRs (30d)
2

Description

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 } };

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided tsconfig.json and webpack.config.js, focusing on the ng-pattern attribute in the AngularJS input. Compare the behavior with the HTML-Loader pull request linked in the report. Done means regex backslashes are preserved in the generated output and the reported pattern remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
angularjs, typescript, webpack
Domain
build-system, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.