Skip to content

fix: only au1 needs legacy decorator #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock
bun.lockb

# Compiled files
dist
Expand Down
4 changes: 1 addition & 3 deletions client/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ const drWorker = dumber({
DUMBER_MODULE_LOADER_DIST
],
deps: [
{name: 'punycode', main: 'punycode.js', lazyMain: true},
// Dumber has not supported package.json exports yet
{name: 'locate-character', main: 'src/index.js'},
{name: 'punycode', main: 'punycode.js', lazyMain: true}
],
append: [
isTest ?
Expand Down
5 changes: 3 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@
"merge2": "^1.4.1",
"moment": "^2.30.1",
"nyc": "^15.1.0",
"sass": "~1.49.11",
"sass-lint": "^1.13.1",
"sass.js": "^0.11.1",
"semver": "^7.6.3",
"source-map": "^0.8.0-beta.0",
"svelte": "^5.14.4",
"svelte": "^5.16.0",
"ts-plugin-inferno": "^6.1.0",
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"zora": "^5.2.0"
"zora": "^6.0.0"
},
"overrides": {
"chokidar": "^3.5.3",
Expand Down
10 changes: 0 additions & 10 deletions client/src-worker/dumber-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ export class DumberSession {
// console.log(`[dumber] `);

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

this.config = config;

Expand All @@ -231,14 +229,6 @@ export class DumberSession {
deps: deps
};

if (usesEsmEnv) {
opts.onRequire = moduleId => {
if (moduleId === 'esm-env') {
return 'export const env = {BROWSER: true, DEV: true, NODE: false};';
}
};
}

this.instance = new this.Dumber(opts);

let transpilerOptions = {};
Expand Down
20 changes: 18 additions & 2 deletions client/src-worker/transpilers/js.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import path from 'path';
import _ from 'lodash';
import transformInferno from 'ts-plugin-inferno';
import * as ts from 'typescript';
import {stripSourceMappingUrl} from 'dumber/lib/shared.js';
const EXTS = ['.js', '.ts', '.jsx', '.tsx'];

function isAurelia1(files) {
const packageJson = _.find(files, {filename: 'package.json'});
if (packageJson) {
try {
const meta = JSON.parse(packageJson.content);
// package "aurelia" is for aurelia 2
return _.has(meta, 'dependencies["aurelia-bootstrapper"]');
} catch (e) {
// ignore
}
}
}

export class JsTranspiler {
match(file) {
const ext = path.extname(file.filename);
Expand All @@ -18,14 +32,16 @@ export class JsTranspiler {

const jsxPragma = opts.jsxPragma || 'React.createElement';
const jsxFrag = opts.jsxFrag || 'React.Fragment';
// Only au1 uses legacy decorators.
const au1 = isAurelia1(files);

const options = {
fileName: filename,
compilerOptions: {
allowJs: true,
checkJs: false,
experimentalDecorators: true,
emitDecoratorMetadata: true,
experimentalDecorators: au1,
emitDecoratorMetadata: au1,
inlineSources: true,
// Don't compile to ModuleKind.AMD because
// dumber can stub some commonjs globals.
Expand Down
Loading