@warp-drive-mirror/build-config 5.4.0-alpha.129 → 5.4.0-alpha.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,12 +15,12 @@ assert('foo', true);
|
|
|
15
15
|
(macroCondition(isDevelopingApp()) ? function assert(test) { if (!test) { throw new Error('foo'); } }(true) : {});
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
// => _macros.getGlobalConfig().
|
|
18
|
+
// => _macros.getGlobalConfig().WarpDriveMirror.env.DEBUG
|
|
19
19
|
function buildMacroConstDEBUG(types, binding, state) {
|
|
20
20
|
return types.memberExpression(types.memberExpression(types.memberExpression(types.callExpression(state.importer.import(binding, '@embroider/macros', 'getGlobalConfig'), []), types.identifier('WarpDriveMirror')), types.identifier('env')), types.identifier('DEBUG'));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
// => _macros.macroCondition(_macros.getGlobalConfig().
|
|
23
|
+
// => _macros.macroCondition(_macros.getGlobalConfig().WarpDriveMirror.env.DEBUG)
|
|
24
24
|
function buildMacroConditionDEBUG(types, binding, state) {
|
|
25
25
|
return types.callExpression(state.importer.import(binding, '@embroider/macros', 'macroCondition'), [buildMacroConstDEBUG(types, binding, state)]);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-transform-asserts.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-asserts.js"],"sourcesContent":["const { ImportUtil } = require('babel-import-util');\n\nconst Utils = new Set(['assert']);\n\n/*\n// Before\nimport { assert } from '@warp-drive-mirror/build-config/macros';\n\nassert('foo', true);\n\n// After\n(macroCondition(isDevelopingApp()) ? function assert(test) { if (!test) { throw new Error('foo'); } }(true) : {});\n*/\n\n// => _macros.getGlobalConfig().
|
|
1
|
+
{"version":3,"file":"babel-plugin-transform-asserts.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-asserts.js"],"sourcesContent":["const { ImportUtil } = require('babel-import-util');\n\nconst Utils = new Set(['assert']);\n\n/*\n// Before\nimport { assert } from '@warp-drive-mirror/build-config/macros';\n\nassert('foo', true);\n\n// After\n(macroCondition(isDevelopingApp()) ? function assert(test) { if (!test) { throw new Error('foo'); } }(true) : {});\n*/\n\n// => _macros.getGlobalConfig().WarpDriveMirror.env.DEBUG\nfunction buildMacroConstDEBUG(types, binding, state) {\n return types.memberExpression(\n types.memberExpression(\n types.memberExpression(\n types.callExpression(state.importer.import(binding, '@embroider/macros', 'getGlobalConfig'), []),\n types.identifier('WarpDriveMirror')\n ),\n types.identifier('env')\n ),\n types.identifier('DEBUG')\n );\n}\n\n// => _macros.macroCondition(_macros.getGlobalConfig().WarpDriveMirror.env.DEBUG)\nfunction buildMacroConditionDEBUG(types, binding, state) {\n return types.callExpression(state.importer.import(binding, '@embroider/macros', 'macroCondition'), [\n buildMacroConstDEBUG(types, binding, state),\n ]);\n}\n\n// (test) => { if (!test) { throw new Error(someMessage); } }(someCond)\nfunction buildAssert(types, originalCallExpression) {\n const desc = originalCallExpression.arguments[0];\n const test = originalCallExpression.arguments[1] ?? types.booleanLiteral(false);\n // prettier-ignore\n return types.callExpression(\n types.arrowFunctionExpression([types.identifier('test')], // (test) =>\n types.blockStatement([ // {\n types.ifStatement( // if\n types.unaryExpression('!', types.identifier('test')), // (!test)\n types.blockStatement([ // {\n types.throwStatement( // throw\n types.newExpression(types.identifier('Error'), [desc]) // new Error(desc)\n )]) // }\n )]) // }\n ),\n [test] // (someCond)\n );\n}\n\n// => ( <debug-macro> ? <assert-exp> : {});\nfunction buildAssertTernary(types, binding, state, originalCallExpression) {\n return types.expressionStatement(\n types.conditionalExpression(\n buildMacroConditionDEBUG(types, binding, state),\n buildAssert(types, originalCallExpression),\n types.objectExpression([])\n )\n );\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === '@warp-drive-mirror/build-config/macros') {\n const specifiers = path.get('specifiers');\n\n specifiers.forEach((specifier) => {\n const name = specifier.node.imported.name;\n if (!Utils.has(name)) {\n throw new Error(`Unexpected import '${name}' imported from '@warp-drive-mirror/build-config/macros'`);\n }\n\n const localBindingName = specifier.node.local.name;\n const binding = specifier.scope.getBinding(localBindingName);\n\n binding.referencePaths.forEach((p) => {\n const originalCallExpression = p.parentPath.node;\n\n if (!t.isCallExpression(originalCallExpression)) {\n throw new Error('Expected a call expression');\n }\n\n const assertTernary = buildAssertTernary(t, binding, state, originalCallExpression);\n p.parentPath.replaceWith(assertTernary);\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["ImportUtil","require","Utils","Set","buildMacroConstDEBUG","types","binding","state","memberExpression","callExpression","importer","import","identifier","buildMacroConditionDEBUG","buildAssert","originalCallExpression","desc","arguments","test","booleanLiteral","arrowFunctionExpression","blockStatement","ifStatement","unaryExpression","throwStatement","newExpression","buildAssertTernary","expressionStatement","conditionalExpression","objectExpression","babel","t","name","visitor","ImportDeclaration","path","importPath","node","source","value","specifiers","get","forEach","specifier","imported","has","Error","localBindingName","local","scope","getBinding","referencePaths","p","parentPath","isCallExpression","assertTernary","replaceWith","removeOwnBinding","remove","length","Program"],"mappings":";;AAAA,MAAM;AAAEA,EAAAA,UAAAA;AAAW,CAAC,GAAGC,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEnD,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASC,oBAAoBA,CAACC,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAE;EACnD,OAAOF,KAAK,CAACG,gBAAgB,CAC3BH,KAAK,CAACG,gBAA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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive-mirror/build-config",
|
|
3
|
-
"version": "5.4.0-alpha.
|
|
3
|
+
"version": "5.4.0-alpha.130",
|
|
4
4
|
"description": "Provides Build Configuration for projects using WarpDrive or EmberData",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-data-mirror",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"semver": "^7.6.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@warp-drive/internal-config": "5.4.0-alpha.
|
|
45
|
+
"@warp-drive/internal-config": "5.4.0-alpha.130",
|
|
46
46
|
"@types/babel__core": "^7.20.5",
|
|
47
47
|
"@types/node": "^20.14.2",
|
|
48
48
|
"@babel/plugin-transform-typescript": "^7.24.5",
|