Skip to content

Commit

Permalink
fix(es/codegen): Use Str.raw for es5 (#8873)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #8871
  • Loading branch information
kdy1 authored Apr 23, 2024
1 parent f5e50c2 commit c7a06b1
Show file tree
Hide file tree
Showing 942 changed files with 3,184 additions and 3,075 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ console.log(true);
if (true) {
console.log("Pass");
}
console.log("foo");
console.log('foo');
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var foo = "\xa0";
var foo = "\u{a0}";
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"''";
"\'\'";
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log("\uD83E\uDD2D \xfc");
console.log("🤭 ü");
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-5xxx/5068/1/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function _templateObject1() {
};
return data;
}
import styled from "styled-components";
import styled from 'styled-components';
var C1 = styled.div(_templateObject());
var C2 = styled.div(_templateObject1());
var debug = eval("");
var debug = eval('');
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-5xxx/5068/2/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function _templateObject1() {
};
return n;
}
import styled from "styled-components";
import styled from 'styled-components';
var C1 = styled.div(_templateObject());
var C2 = styled.div(_templateObject1());
var debug = eval("");
var debug = eval('');
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log("exists");
console.log('exists');
10 changes: 5 additions & 5 deletions crates/swc/tests/fixture/issues-5xxx/5556/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ x = function x1() {
var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(app) {
return {
schedule: {
interval: "1m",
type: "all",
disable: app.config.env === "local"
interval: '1m',
type: 'all',
disable: app.config.env === 'local'
},
task: function task(ctx) {
var res;
Expand All @@ -16,8 +16,8 @@ x = function x1() {
case 0:
return [
4,
ctx.curl("http://www.api.com/cache", {
contentType: "json"
ctx.curl('http://www.api.com/cache', {
contentType: 'json'
})
];
case 1:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var foo = function o() {};
console.log("PASS");
console.log('PASS');
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "core-js/modules/es.array.at.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.string.at-alternative.js";
import "core-js/modules/es.string.split.js";
"1.2.3".split(".").at(-1);
'1.2.3'.split('.').at(-1);
[
123,
456
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"use client";
'use client';
foo(function() {});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use client";
'use client';
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _create_class } from "@swc/helpers/_/_create_class";
export var Foo = /*#__PURE__*/ function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use client";
'use client';
export var Foo = {
foo: function foo() {}
};
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-6xxx/6888/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "core-js/modules/es.string.at-alternative.js";
import "core-js/modules/es.string.replace-all.js";
import "core-js/modules/es.string.replace.js";
import "core-js/modules/es.string.split.js";
"test".replaceAll("", "");
"1.2.3".split(".").at(-1);
'test'.replaceAll('', '');
'1.2.3'.split('.').at(-1);
[
123
].at(1);
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/issues-6xxx/6898/output/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ _async_to_generator(function() {
_loop = function(i) {
var value = arr[i];
setTimeout(function() {
console.log("value", value);
console.log('value', value);
}, 0);
};
arr = [
"value1",
"value2",
"value3"
'value1',
'value2',
'value3'
];
// for (const value of arr) {
for(i = 0; i < arr.length; i++)_loop(i);
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-6xxx/6984/1/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { _ as _create_class } from "@swc/helpers/_/_create_class";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
import React from "react";
import { withRouter } from "react-router-dom";
import React from 'react';
import { withRouter } from 'react-router-dom';
var App = function(_React_Component) {
"use strict";
_inherits(App, _React_Component);
Expand Down
6 changes: 3 additions & 3 deletions crates/swc/tests/fixture/issues-7xxx/7240/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Object.defineProperty(exports, "__esModule", {
}
});
var _obj, _default = ((_obj = {
\u3131: "\u11B0",
\u3141: "\u11B1"
})["\u3142"] = "\u11B2", _obj);
\u3131: '\u11B0',
\u3141: '\u11B1'
})['\u3142'] = '\u11B2', _obj);
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7253/output/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ var bmRnd;
function a() {
bmRnd = function bmRnd1() {};
}
eval("");
eval('');
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7546/output/1.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { ClassName } from "./some-file";
import { ClassName } from './some-file';
export default {
field: /*#__PURE__*/ function(ClassName) {
"use strict";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
1,
2
], [
"foo",
'foo',
3
], [
4
], [
"bar",
'bar',
5
], [
[
"baz",
'baz',
6
],
7,
Expand Down
18 changes: 9 additions & 9 deletions crates/swc/tests/fixture/issues-7xxx/7805/output/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ var SUPPORTED_LOCALE = {
tr: {
regexp: /\u0130|\u0049|\u0049\u0307/g,
map: {
\u0130: "i",
\u0130: "\u0069",
I: "\u0131",
I\u0307: "i"
I\u0307: "\u0069"
}
},
az: {
regexp: /\u0130/g,
map: {
\u0130: "i",
\u0130: "\u0069",
I: "\u0131",
I\u0307: "i"
I\u0307: "\u0069"
}
},
lt: {
regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
map: {
I: "i\u0307",
J: "j\u0307",
I: "\u0069\u0307",
J: "\u006A\u0307",
\u012E: "\u012F\u0307",
"\xcc": "i\u0307\u0300",
"\xcd": "i\u0307\u0301",
\u0128: "i\u0307\u0303"
"\xcc": "\u0069\u0307\u0300",
"\xcd": "\u0069\u0307\u0301",
\u0128: "\u0069\u0307\u0303"
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7821/output/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var Blocks = {
},
Layout1: function() {
return [
"Block1"
'Block1'
].map(function(e) {
return Blocks[e];
});
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-8xxx/8185/output/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { _ as _define_property } from "@swc/helpers/_/_define_property";
var a = function() {
var _define_property1 = 1;
var fn = function() {
return console.log(_define_property({}, prop, "test"));
return console.log(_define_property({}, prop, 'test'));
};
};
var b = function() {
return eval("console.log()");
return eval('console.log()');
};
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-8xxx/8185/output/input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function hello() {
console.log("outer stack", new Error().stack);
console.log('outer stack', new Error().stack);
})();
eval("");
12 changes: 6 additions & 6 deletions crates/swc/tests/fixture/issues-8xxx/8193/output/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ require("core-js/modules/es.object.create.js");
require("core-js/modules/esnext.object.group-by.js");
var data = [
{
name: "a",
type: "a"
name: 'a',
type: 'a'
},
{
name: "b",
type: "a"
name: 'b',
type: 'a'
},
{
name: "c",
type: "b"
name: 'c',
type: 'b'
}
];
var result = Object.groupBy(data, function(param) {
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-8xxx/8345/output/1.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var data = "\\ud";
var data = '\\ud';
console.log(data);
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-8xxx/8435/output/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var e;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _create_class } from "@swc/helpers/_/_create_class";
(e = window.parcelRequire).register("module1", function() {}), e.register("module2", function() {
console.log("test");
(e = window.parcelRequire).register('module1', function() {}), e.register('module2', function() {
console.log('test');
});
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-8xxx/8482/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
return a;
}
});
let a = "";
let a = '';
});
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/issues-8xxx/8616/output/1.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var Module = (function() {
var _scriptDir = typeof document !== "undefined" && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== "undefined") _scriptDir || (_scriptDir = __filename);
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir || (_scriptDir = __filename);
return function() {
var moduleArg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
var Module = moduleArg;
Expand All @@ -13,7 +13,7 @@ var Module = (function() {
return moduleArg;
};
})()();
if (typeof exports === "object" && typeof module === "object") module.exports = Module;
else if (typeof define === "function" && define["amd"]) define([], function() {
if (typeof exports === 'object' && typeof module === 'object') module.exports = Module;
else if (typeof define === 'function' && define['amd']) define([], function() {
return Module;
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
import { Test } from "@nestjs/testing";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
describe("AppController", function() {
describe('AppController', function() {
var app;
beforeAll(/*#__PURE__*/ _async_to_generator(function() {
return _ts_generator(this, function(_state) {
Expand All @@ -28,10 +28,10 @@ describe("AppController", function() {
}
});
}));
describe("getHello", function() {
describe('getHello', function() {
it('should return "Hello World!"', function() {
var appController = app.get(AppController);
expect(appController.getHello()).toBe("Hello World!");
expect(appController.getHello()).toBe('Hello World!');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export var AppService = /*#__PURE__*/ function() {
{
key: "getHello",
value: function getHello() {
return "Hello World!";
return 'Hello World!';
}
}
]);
Expand Down
19 changes: 19 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8863/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false
},
"target": "es5",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}
1 change: 1 addition & 0 deletions crates/swc/tests/fixture/issues-8xxx/8863/input/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`pattern="\x5cd"`;
1 change: 1 addition & 0 deletions crates/swc/tests/fixture/issues-8xxx/8863/output/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'pattern="\\d"';
25 changes: 25 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8871/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"loose": true,
"minify": {
"compress": false,
"mangle": false
},
"transform": {
"react": {
"runtime": "classic",
"development": false
}
},
"target": "es5"
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}
5 changes: 5 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8871/input/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const x = "</" + "script>"
const y = "<\/script>"
const z = "\/\/ \\"

export { x, y, z }
4 changes: 4 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8871/output/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var x = "</" + "script>";
var y = "<\/script>";
var z = "\/\/ \\";
export { x, y, z };
Loading

0 comments on commit c7a06b1

Please sign in to comment.