@nullvoxpopuli/ember-vite 1.0.0 → 1.0.1
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/LICENSE +21 -0
- package/package.json +7 -6
- package/src/ember.ts +4 -4
- package/src/maybe-babel.ts +25 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NullVoxPopuli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nullvoxpopuli/ember-vite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Meta plugin for ember projects focusing on speed.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -11,15 +11,16 @@
|
|
|
11
11
|
],
|
|
12
12
|
"author": "NullVoxPopuli",
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/NullVoxPopuli/ember.nvp",
|
|
17
|
+
"directory": "packages/vite"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@babel/core": "^7.28.6",
|
|
20
21
|
"@embroider/core": "^4.4.2",
|
|
21
22
|
"@embroider/vite": "^1.5.0",
|
|
22
|
-
"@rollup/plugin-babel": "^
|
|
23
|
+
"@rollup/plugin-babel": "^7.1.0",
|
|
23
24
|
"oxc-parser": "^0.132.0",
|
|
24
25
|
"oxc-transform": "^0.132.0",
|
|
25
26
|
"zimmerframe": "^1.1.4"
|
|
@@ -31,4 +32,4 @@
|
|
|
31
32
|
"typescript": "^5.9.3",
|
|
32
33
|
"vite": "^8.0.14"
|
|
33
34
|
}
|
|
34
|
-
}
|
|
35
|
+
}
|
package/src/ember.ts
CHANGED
|
@@ -50,8 +50,8 @@ interface Config {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export function ember(nvpConfig: Config) {
|
|
54
|
-
const babelConfigFile = resolve(join(process.cwd(), "./babel.config.
|
|
53
|
+
export function ember(nvpConfig: Config = {}) {
|
|
54
|
+
const babelConfigFile = resolve(join(process.cwd(), "./babel.config.js"));
|
|
55
55
|
const defaultEnv = { mode: process.env.NODE_ENV || "development" };
|
|
56
56
|
|
|
57
57
|
/*
|
|
@@ -114,11 +114,11 @@ export function ember(nvpConfig: Config) {
|
|
|
114
114
|
|
|
115
115
|
const MODE_DEV = "development";
|
|
116
116
|
|
|
117
|
-
function isDev(mode) {
|
|
117
|
+
function isDev(mode: string) {
|
|
118
118
|
return mode === MODE_DEV;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
function applyConfig(viteConfig: ResolvedConfig, env, nvpConfig: Config) {
|
|
121
|
+
function applyConfig(viteConfig: ResolvedConfig, env: ConfigEnv, nvpConfig: Config) {
|
|
122
122
|
if (isDev(env.mode)) {
|
|
123
123
|
return dev(viteConfig, nvpConfig);
|
|
124
124
|
}
|
package/src/maybe-babel.ts
CHANGED
|
@@ -57,7 +57,7 @@ const counts = {
|
|
|
57
57
|
export function maybeBabel(options: { parallel?: boolean; configFile: string; env: any }) {
|
|
58
58
|
const { env, parallel, ...restOptions } = options;
|
|
59
59
|
const original = (() => {
|
|
60
|
-
const babelPath = resolve(join(process.cwd(), "./babel.config.
|
|
60
|
+
const babelPath = resolve(join(process.cwd(), "./babel.config.js"));
|
|
61
61
|
|
|
62
62
|
return babel({
|
|
63
63
|
babelHelpers: "runtime",
|
|
@@ -65,46 +65,57 @@ export function maybeBabel(options: { parallel?: boolean; configFile: string; en
|
|
|
65
65
|
skipPreflightCheck: true,
|
|
66
66
|
...restOptions,
|
|
67
67
|
configFile: babelPath,
|
|
68
|
-
|
|
69
|
-
// https://github.com/rollup/plugins/pull/1956
|
|
70
|
-
// parallel: parallel ?? true,
|
|
68
|
+
parallel: parallel ?? true,
|
|
71
69
|
});
|
|
72
70
|
})();
|
|
73
71
|
|
|
72
|
+
/**
|
|
73
|
+
* In @rollup/plugin-babel v7+, the `transform` hook is the object form
|
|
74
|
+
* `{ filter, handler }` rather than a plain function. Normalize to the
|
|
75
|
+
* underlying handler so we can invoke it directly.
|
|
76
|
+
*/
|
|
77
|
+
const originalTransform = (
|
|
78
|
+
typeof original.transform === "function" ? original.transform : original.transform?.handler
|
|
79
|
+
)!;
|
|
80
|
+
|
|
74
81
|
const babelMacros = new Set(babelRequiredImports);
|
|
75
82
|
if (env.mode === "development") {
|
|
76
83
|
babelMacros.delete("@ember/debug");
|
|
77
84
|
}
|
|
78
85
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
async function doTransform(code, id) {
|
|
86
|
+
async function doTransform(this: any, code: string, id: string) {
|
|
82
87
|
counts.total++;
|
|
83
88
|
|
|
84
89
|
const ext = id.split(".").at(-1);
|
|
85
|
-
const lang = ext === "gjs" ? "js" : ext === "gts" ? "ts" : ext
|
|
90
|
+
const lang = (ext === "gjs" ? "js" : ext === "gts" ? "ts" : ext) as
|
|
91
|
+
| "js"
|
|
92
|
+
| "ts"
|
|
93
|
+
| "jsx"
|
|
94
|
+
| "tsx"
|
|
95
|
+
| "dts"
|
|
96
|
+
| undefined;
|
|
86
97
|
|
|
87
98
|
let needsBabel = false;
|
|
88
99
|
|
|
89
100
|
const estree = await oxcParse(id, code, { lang });
|
|
90
101
|
|
|
91
102
|
walk(
|
|
92
|
-
estree.program,
|
|
103
|
+
estree.program as any,
|
|
93
104
|
/* state */ {},
|
|
94
105
|
{
|
|
95
|
-
Decorator(_node, { stop }) {
|
|
106
|
+
Decorator(_node: any, { stop }: any) {
|
|
96
107
|
needsBabel = true;
|
|
97
108
|
counts.why.decorators++;
|
|
98
109
|
stop();
|
|
99
110
|
},
|
|
100
|
-
MemberExpression(node, { stop }) {
|
|
111
|
+
MemberExpression(node: any, { stop }: any) {
|
|
101
112
|
if (node.property?.name === "formatMessage" && node.object?.name === "intl") {
|
|
102
113
|
needsBabel = true;
|
|
103
114
|
counts.why.formatMessage++;
|
|
104
115
|
stop();
|
|
105
116
|
}
|
|
106
117
|
},
|
|
107
|
-
ImportDeclaration(node, { stop }) {
|
|
118
|
+
ImportDeclaration(node: any, { stop }: any) {
|
|
108
119
|
const value = node.source.value;
|
|
109
120
|
if (babelMacros.has(value)) {
|
|
110
121
|
needsBabel = true;
|
|
@@ -131,7 +142,7 @@ export function maybeBabel(options: { parallel?: boolean; configFile: string; en
|
|
|
131
142
|
if (needsBabel) {
|
|
132
143
|
counts.babel++;
|
|
133
144
|
|
|
134
|
-
const result = await
|
|
145
|
+
const result = await originalTransform.call(this, code, id);
|
|
135
146
|
|
|
136
147
|
return result;
|
|
137
148
|
}
|
|
@@ -193,7 +204,7 @@ export function maybeBabel(options: { parallel?: boolean; configFile: string; en
|
|
|
193
204
|
// include: [/initializeRuntimeMacrosConfig/, /precompileTemplate/],
|
|
194
205
|
// },
|
|
195
206
|
},
|
|
196
|
-
handler(code, id) {
|
|
207
|
+
handler(this: any, code: string, id: string) {
|
|
197
208
|
try {
|
|
198
209
|
return doTransform.call(this, code, id);
|
|
199
210
|
} catch (e) {
|