@embroider/test-setup 4.0.0 → 4.0.1-unstable.01e21e6
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 +8 -7
- package/src/index.js +26 -10
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@embroider/test-setup",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.1-unstable.01e21e6",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "https://github.com/embroider-build/embroider.git",
|
@@ -12,19 +12,20 @@
|
|
12
12
|
"src/index.js"
|
13
13
|
],
|
14
14
|
"dependencies": {
|
15
|
+
"broccoli-plugin": "^4.0.7",
|
15
16
|
"lodash": "^4.17.21",
|
16
17
|
"resolve": "^1.20.0"
|
17
18
|
},
|
18
19
|
"devDependencies": {
|
19
20
|
"@types/lodash": "^4.14.170",
|
20
|
-
"@embroider/compat": "^3.
|
21
|
-
"@embroider/
|
22
|
-
"@embroider/
|
21
|
+
"@embroider/compat": "^3.7.1-unstable.01e21e6",
|
22
|
+
"@embroider/webpack": "^4.0.9-unstable.01e21e6",
|
23
|
+
"@embroider/core": "^3.4.20-unstable.01e21e6"
|
23
24
|
},
|
24
25
|
"peerDependencies": {
|
25
|
-
"@embroider/
|
26
|
-
"@embroider/
|
27
|
-
"@embroider/
|
26
|
+
"@embroider/compat": "^3.7.1-unstable.01e21e6",
|
27
|
+
"@embroider/webpack": "^4.0.9-unstable.01e21e6",
|
28
|
+
"@embroider/core": "^3.4.20-unstable.01e21e6"
|
28
29
|
},
|
29
30
|
"peerDependenciesMeta": {
|
30
31
|
"@embroider/compat": {
|
package/src/index.js
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
6
|
+
exports.maybeEmbroider = maybeEmbroider;
|
7
|
+
exports.embroiderSafe = embroiderSafe;
|
8
|
+
exports.embroiderOptimized = embroiderOptimized;
|
9
|
+
const broccoli_plugin_1 = __importDefault(require("broccoli-plugin"));
|
10
|
+
const child_process_1 = require("child_process");
|
4
11
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
5
12
|
const ourPeerDeps = require('../package.json').peerDependencies;
|
6
13
|
const embroiderDevDeps = {
|
@@ -18,16 +25,12 @@ const embroiderDevDeps = {
|
|
18
25
|
*/
|
19
26
|
function maybeEmbroider(app, opts = {}) {
|
20
27
|
if (!shouldUseEmbroider(app)) {
|
21
|
-
return app.toTree(
|
28
|
+
return app.toTree();
|
22
29
|
}
|
23
30
|
// we're using `require` here on purpose because
|
24
31
|
// - we don't want to load any of these things until they're actually needed;
|
25
32
|
// - we can't use `await import()` because this function needs to be synchronous to go inside ember-cli-build.js
|
26
33
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
27
|
-
let { Webpack } = require(require.resolve('@embroider/webpack', {
|
28
|
-
paths: [app.project.root],
|
29
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
30
|
-
}));
|
31
34
|
let Compat = require(require.resolve('@embroider/compat', {
|
32
35
|
paths: [app.project.root],
|
33
36
|
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
@@ -45,9 +48,24 @@ function maybeEmbroider(app, opts = {}) {
|
|
45
48
|
throw new Error(`No such scenario EMBROIDER_TEST_SETUP_OPTIONS=${process.env.EMBROIDER_TEST_SETUP_OPTIONS}`);
|
46
49
|
}
|
47
50
|
}
|
48
|
-
|
51
|
+
if (process.env.EMBROIDER_PREBUILD) {
|
52
|
+
return Compat.prebuild(app, opts);
|
53
|
+
}
|
54
|
+
return new BuildWithVite([]);
|
55
|
+
}
|
56
|
+
class BuildWithVite extends broccoli_plugin_1.default {
|
57
|
+
build() {
|
58
|
+
return new Promise((resolve, reject) => {
|
59
|
+
const child = (0, child_process_1.spawn)(`npx vite build --outDir ${this.outputPath}`, {
|
60
|
+
cwd: process.cwd(),
|
61
|
+
shell: true,
|
62
|
+
stdio: 'inherit',
|
63
|
+
env: { ...process.env },
|
64
|
+
});
|
65
|
+
child.on('exit', code => (code === 0 ? resolve() : reject(new Error('vite build failed'))));
|
66
|
+
});
|
67
|
+
}
|
49
68
|
}
|
50
|
-
exports.maybeEmbroider = maybeEmbroider;
|
51
69
|
function embroiderSafe(extension) {
|
52
70
|
return extendScenario({
|
53
71
|
name: 'embroider-safe',
|
@@ -59,7 +77,6 @@ function embroiderSafe(extension) {
|
|
59
77
|
},
|
60
78
|
}, extension);
|
61
79
|
}
|
62
|
-
exports.embroiderSafe = embroiderSafe;
|
63
80
|
function embroiderOptimized(extension) {
|
64
81
|
return extendScenario({
|
65
82
|
name: 'embroider-optimized',
|
@@ -71,7 +88,6 @@ function embroiderOptimized(extension) {
|
|
71
88
|
},
|
72
89
|
}, extension);
|
73
90
|
}
|
74
|
-
exports.embroiderOptimized = embroiderOptimized;
|
75
91
|
function extendScenario(scenario, extension) {
|
76
92
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/consistent-type-imports
|
77
93
|
let mergeWith = require('lodash/mergeWith');
|