@embroider/compat 4.0.0-alpha.5 → 4.0.0-alpha.6
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.
- package/package.json +4 -4
- package/src/babel.js +4 -14
- package/src/babel.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/compat",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Backward compatibility layer for the Embroider build system.",
|
|
6
6
|
"repository": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"tree-sync": "^2.1.0",
|
|
69
69
|
"typescript-memoize": "^1.0.1",
|
|
70
70
|
"walk-sync": "^3.0.0",
|
|
71
|
-
"@embroider/macros": "1.17.0-alpha.
|
|
71
|
+
"@embroider/macros": "1.17.0-alpha.5"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@glimmer/syntax": "^0.84.3",
|
|
@@ -91,12 +91,12 @@
|
|
|
91
91
|
"ember-engines": "^0.8.19",
|
|
92
92
|
"scenario-tester": "^4.0.0",
|
|
93
93
|
"typescript": "^5.4.5",
|
|
94
|
-
"@embroider/core": "^4.0.0-alpha.5",
|
|
95
94
|
"@embroider/sample-transforms": "0.0.0",
|
|
95
|
+
"@embroider/core": "^4.0.0-alpha.6",
|
|
96
96
|
"@embroider/test-support": "0.36.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
|
-
"@embroider/core": "^4.0.0-alpha.
|
|
99
|
+
"@embroider/core": "^4.0.0-alpha.6"
|
|
100
100
|
},
|
|
101
101
|
"engines": {
|
|
102
102
|
"node": "12.* || 14.* || >= 16"
|
package/src/babel.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.pluginsFromV1Addons = pluginsFromV1Addons;
|
|
7
4
|
exports.transformsFromV1Addons = transformsFromV1Addons;
|
|
@@ -15,26 +12,19 @@ exports.templateCompatSupport = templateCompatSupport;
|
|
|
15
12
|
const fs_1 = require("fs");
|
|
16
13
|
const core_1 = require("@embroider/core");
|
|
17
14
|
const path_1 = require("path");
|
|
18
|
-
const
|
|
15
|
+
const babel_1 = require("@embroider/macros/babel");
|
|
19
16
|
function loadCompatConfig() {
|
|
20
17
|
let compatFile = (0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(process.cwd()), '_babel_compat_.js');
|
|
21
18
|
if ((0, fs_1.existsSync)(compatFile)) {
|
|
22
19
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
23
20
|
return require(compatFile);
|
|
24
21
|
}
|
|
25
|
-
let macros =
|
|
26
|
-
let { plugins: templateMacros, setConfig } = macros_config_1.default.transforms();
|
|
27
|
-
setConfig(macros);
|
|
28
|
-
if (process.env.NODE_ENV === 'development') {
|
|
29
|
-
macros.enablePackageDevelopment(process.cwd());
|
|
30
|
-
macros.enableRuntimeMode();
|
|
31
|
-
}
|
|
32
|
-
macros.finalize();
|
|
22
|
+
let macros = (0, babel_1.buildMacros)();
|
|
33
23
|
return {
|
|
34
24
|
plugins: [],
|
|
35
25
|
templateTransforms: [],
|
|
36
|
-
babelMacros: macros.
|
|
37
|
-
templateMacros: templateMacros,
|
|
26
|
+
babelMacros: macros.babelMacros,
|
|
27
|
+
templateMacros: macros.templateMacros,
|
|
38
28
|
};
|
|
39
29
|
}
|
|
40
30
|
const resolverLoader = new core_1.ResolverLoader(process.cwd());
|
package/src/babel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel.js","sourceRoot":"","sources":["babel.ts"],"names":[],"mappings":"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F,uEAAuE;QACvE,4CAA4C;QAC5C,EAAE;QACF,+DAA+D;QAC/D,6DAA6D;QAC7D,wEAAwE;QACxE,sEAAsE;QACtE,gBAAgB;QAChB,EAAE;QACF,yEAAyE;QACzE,wEAAwE;QACxE,kBAAkB;QAClB,kBAAkB,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;QAEvC,oEAAoE;QACpE,wEAAwE;QACxE,sEAAsE;QACtE,YAAY,EAAE,IAAI;KACnB,CAAC;IACF,OAAO,CAAC,mCAA4B,EAAE,iBAAiB,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,kBAAkB;IAChC,OAAO,CAAC,GAAG,WAAW,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,kBAAkB,EAAE,EAAE,GAAG,mBAAmB,EAAE,CAAC,CAAC;AACjG,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO,CAAC,GAAG,sBAAsB,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import type { PluginItem } from '@babel/core';\nimport { existsSync } from 'fs';\nimport {\n locateEmbroiderWorkingDir,\n ResolverLoader,\n templateColocationPluginPath,\n type TemplateColocationPluginOptions,\n} from '@embroider/core';\nimport { join } from 'path';\nimport type { Transform } from 'babel-plugin-ember-template-compilation';\nimport type { Options as ResolverTransformOptions } from './resolver-transform';\nimport { buildMacros } from '@embroider/macros/babel';\n\nexport interface CompatBabelState {\n plugins: PluginItem[];\n templateTransforms: Transform[];\n babelMacros: PluginItem[];\n templateMacros: Transform[];\n}\n\nfunction loadCompatConfig(): CompatBabelState {\n let compatFile = join(locateEmbroiderWorkingDir(process.cwd()), '_babel_compat_.js');\n if (existsSync(compatFile)) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(compatFile);\n }\n\n let macros = buildMacros();\n\n return {\n plugins: [],\n templateTransforms: [],\n babelMacros: macros.babelMacros,\n templateMacros: macros.templateMacros as any,\n };\n}\n\nconst resolverLoader = new ResolverLoader(process.cwd());\n\nexport function pluginsFromV1Addons() {\n let config = loadCompatConfig();\n return config.plugins;\n}\n\nexport function transformsFromV1Addons() {\n let config = loadCompatConfig();\n return config.templateTransforms;\n}\n\nexport function looseModeSupport(): Transform {\n const { resolver } = resolverLoader;\n let opts: ResolverTransformOptions = {\n appRoot: resolver.options.appRoot,\n emberVersion: resolver.options.emberVersion,\n };\n return [require.resolve('./resolver-transform'), opts];\n}\n\nexport function templateMacros() {\n let config = loadCompatConfig();\n return config.templateMacros;\n}\n\nexport function babelMacros() {\n let config = loadCompatConfig();\n return config.babelMacros;\n}\n\nexport function oldDebugMacros(): PluginItem[] {\n let debugMacros = require.resolve('babel-plugin-debug-macros');\n return [\n [\n debugMacros,\n {\n flags: [\n {\n source: '@glimmer/env',\n flags: {\n DEBUG: true,\n CI: false,\n },\n },\n ],\n debugTools: {\n isDebug: true,\n source: '@ember/debug',\n assertPredicateIndex: 1,\n },\n externalizeHelpers: {\n module: '@ember/debug',\n },\n },\n '@ember/debug stripping',\n ],\n [\n debugMacros,\n {\n externalizeHelpers: {\n module: '@ember/application/deprecations',\n },\n debugTools: {\n isDebug: true,\n source: '@ember/application/deprecations',\n assertPredicateIndex: 1,\n },\n },\n '@ember/application/deprecations stripping',\n ],\n ];\n}\n\nexport function templateColocation(): PluginItem {\n let colocationOptions: TemplateColocationPluginOptions = {\n appRoot: resolverLoader.resolver.options.appRoot,\n\n // This extra weirdness is a compromise in favor of build performance.\n //\n // 1. When auto-upgrading an addon from v1 to v2, we definitely want to\n // run any custom AST transforms in stage1.\n //\n // 2. In general case, AST transforms are allowed to manipulate Javascript\n // scope. This means that running transforms -- even when we're doing\n // source-to-source compilation that emits handlebars and not wire\n // format -- implies changing .hbs files into .js files.\n //\n // 3. So stage1 may need to rewrite .hbs to .hbs.js (to avoid colliding\n // with an existing co-located .js file).\n //\n // 4. But stage1 doesn't necessarily want to run babel over the\n // corresponding JS file. Most of the time, that's just an\n // unnecessarily expensive second parse. (We only run it in stage1 to\n // eliminate an addon's custom babel plugins, and many addons don't\n // have any.)\n //\n // 5. Therefore, the work of template-colocation gets defered until here,\n // and it may see co-located templates named `.hbs.js` instead of the\n // usual `.hbs.\n templateExtensions: ['.hbs', '.hbs.js'],\n\n // All of the above only applies to auto-upgraded packages that were\n // authored in v1. V2 packages don't get any of this complexity, they're\n // supposed to take care of colocating their own templates explicitly.\n packageGuard: true,\n };\n return [templateColocationPluginPath, colocationOptions];\n}\n\nexport function babelCompatSupport(): PluginItem[] {\n return [...babelMacros(), ...oldDebugMacros(), templateColocation(), ...pluginsFromV1Addons()];\n}\n\nexport function templateCompatSupport(): Transform[] {\n return [...transformsFromV1Addons(), ...templateMacros(), looseModeSupport()];\n}\n"]}
|