Skip to content

Commit

Permalink
🏗 Remove freeze optiion from babel-plugin-transform-json-import (#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorozco committed Nov 1, 2021
1 parent 485615b commit 64e6e43
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 78 deletions.
5 changes: 1 addition & 4 deletions build-system/babel-config/minified-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ function getMinifiedConfig() {
'./build-system/babel-plugins/babel-plugin-transform-log-methods',
{replaceCallArguments: false},
],
[
'./build-system/babel-plugins/babel-plugin-transform-json-import',
{freeze: false},
],
'./build-system/babel-plugins/babel-plugin-transform-json-import',
'./build-system/babel-plugins/babel-plugin-transform-amp-extension-call',
'./build-system/babel-plugins/babel-plugin-transform-html-template',
'./build-system/babel-plugins/babel-plugin-transform-jss',
Expand Down
5 changes: 1 addition & 4 deletions build-system/babel-config/pre-closure-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ function getPreClosureConfig() {
{replaceCallArguments: false},
],
'./build-system/babel-plugins/babel-plugin-transform-parenthesize-expression',
[
'./build-system/babel-plugins/babel-plugin-transform-json-import',
{freeze: false},
],
'./build-system/babel-plugins/babel-plugin-transform-json-import',
'./build-system/babel-plugins/babel-plugin-transform-amp-extension-call',
'./build-system/babel-plugins/babel-plugin-transform-html-template',
'./build-system/babel-plugins/babel-plugin-transform-jss',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ const {readFileSync} = require('fs');
* ```
*
* @param {babel} babel
* @param {any} options
* @return {babel.PluginObj}
*/
module.exports = function (babel, options) {
module.exports = function (babel) {
const {template, types: t} = babel;
const {freeze = true} = options;

/**
* JSON reviver that converts {"string": "foo", ...} to just "foo".
Expand Down Expand Up @@ -99,19 +97,6 @@ module.exports = function (babel, options) {
);
}

if (freeze) {
path.replaceWith(
template.statement
.ast`const ${specifier} = JSON.parse('${JSON.stringify(
json
)}', function(key, val) {
if (typeof val === 'object') Object.freeze(val);
return val;
});`
);
return;
}

path.replaceWith(
template.statement
.ast`const ${specifier} = JSON.parse('${JSON.stringify(json)}');`
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
// options.js is left as is
// lang.json is minified because the path includes /_locales/
const options = JSON.parse("{\"plugins\":[\"../../../..\"],\"sourceType\":\"module\"}", function (key, val) {
if (typeof val === 'object') Object.freeze(val);
return val;
});
const lang = JSON.parse("{\"2\":\"foo\",\"15\":\"bar\"}", function (key, val) {
if (typeof val === 'object') Object.freeze(val);
return val;
});
const options = JSON.parse("{\"plugins\":[\"../../../..\"],\"sourceType\":\"module\"}");
const lang = JSON.parse("{\"2\":\"foo\",\"15\":\"bar\"}");

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
const key = JSON.parse("{\"plugins\":[\"../../../..\"],\"sourceType\":\"module\"}", function (key, val) {
if (typeof val === 'object') Object.freeze(val);
return val;
});
const string = JSON.parse("{\"plugins\":[\"../../../..\"],\"sourceType\":\"module\"}", function (key, val) {
if (typeof val === 'object') Object.freeze(val);
return val;
});
const key = JSON.parse("{\"plugins\":[\"../../../..\"],\"sourceType\":\"module\"}");
const string = JSON.parse("{\"plugins\":[\"../../../..\"],\"sourceType\":\"module\"}");

0 comments on commit 64e6e43

Please sign in to comment.