Skip to content

Commit 08824a5

Browse files
committed
fix: only au1 needs legacy decorator
1 parent 4956cda commit 08824a5

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
package-lock.json
1212
pnpm-lock.yaml
1313
yarn.lock
14+
bun.lockb
1415

1516
# Compiled files
1617
dist

client/gulpfile.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ const drWorker = dumber({
125125
DUMBER_MODULE_LOADER_DIST
126126
],
127127
deps: [
128-
{name: 'punycode', main: 'punycode.js', lazyMain: true},
129-
// Dumber has not supported package.json exports yet
130-
{name: 'locate-character', main: 'src/index.js'},
128+
{name: 'punycode', main: 'punycode.js', lazyMain: true}
131129
],
132130
append: [
133131
isTest ?

client/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@
3939
"merge2": "^1.4.1",
4040
"moment": "^2.30.1",
4141
"nyc": "^15.1.0",
42+
"sass": "~1.49.11",
4243
"sass-lint": "^1.13.1",
4344
"sass.js": "^0.11.1",
4445
"semver": "^7.6.3",
4546
"source-map": "^0.8.0-beta.0",
46-
"svelte": "^5.14.4",
47+
"svelte": "^5.16.0",
4748
"ts-plugin-inferno": "^6.1.0",
4849
"tslib": "^2.8.1",
4950
"typescript": "^5.7.2",
50-
"zora": "^5.2.0"
51+
"zora": "^6.0.0"
5152
},
5253
"overrides": {
5354
"chokidar": "^3.5.3",

client/src-worker/dumber-session.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ export class DumberSession {
205205
// console.log(`[dumber] `);
206206

207207
const isAurelia1 = _.some(deps, {name: 'aurelia-bootstrapper'});
208-
// package "esm-env" uses "exports" in package.json that dumber is yet to support.
209-
const usesEsmEnv = _.some(deps, {name: 'esm-env'});
210208

211209
this.config = config;
212210

@@ -231,14 +229,6 @@ export class DumberSession {
231229
deps: deps
232230
};
233231

234-
if (usesEsmEnv) {
235-
opts.onRequire = moduleId => {
236-
if (moduleId === 'esm-env') {
237-
return 'export const env = {BROWSER: true, DEV: true, NODE: false};';
238-
}
239-
};
240-
}
241-
242232
this.instance = new this.Dumber(opts);
243233

244234
let transpilerOptions = {};

client/src-worker/transpilers/js.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
import path from 'path';
2+
import _ from 'lodash';
23
import transformInferno from 'ts-plugin-inferno';
34
import * as ts from 'typescript';
45
import {stripSourceMappingUrl} from 'dumber/lib/shared.js';
56
const EXTS = ['.js', '.ts', '.jsx', '.tsx'];
67

8+
function isAurelia1(files) {
9+
const packageJson = _.find(files, {filename: 'package.json'});
10+
if (packageJson) {
11+
try {
12+
const meta = JSON.parse(packageJson.content);
13+
// package "aurelia" is for aurelia 2
14+
return _.has(meta, 'dependencies["aurelia-bootstrapper"]');
15+
} catch (e) {
16+
// ignore
17+
}
18+
}
19+
}
20+
721
export class JsTranspiler {
822
match(file) {
923
const ext = path.extname(file.filename);
@@ -18,14 +32,16 @@ export class JsTranspiler {
1832

1933
const jsxPragma = opts.jsxPragma || 'React.createElement';
2034
const jsxFrag = opts.jsxFrag || 'React.Fragment';
35+
// Only au1 uses legacy decorators.
36+
const au1 = isAurelia1(files);
2137

2238
const options = {
2339
fileName: filename,
2440
compilerOptions: {
2541
allowJs: true,
2642
checkJs: false,
27-
experimentalDecorators: true,
28-
emitDecoratorMetadata: true,
43+
experimentalDecorators: au1,
44+
emitDecoratorMetadata: au1,
2945
inlineSources: true,
3046
// Don't compile to ModuleKind.AMD because
3147
// dumber can stub some commonjs globals.

0 commit comments

Comments
 (0)