Skip to content

Commit 5c551c7

Browse files
committed
feat: Add new version of SWC to fix gulpjs#98
From fork codermarcos/interpret On branch master Changes to be committed: modified: index.js
1 parent 972be61 commit 5c551c7

File tree

1 file changed

+233
-82
lines changed

1 file changed

+233
-82
lines changed

Diff for: index.js

+233-82
Original file line numberDiff line numberDiff line change
@@ -263,100 +263,204 @@ var extensions = {
263263
hook.registerTSX(config);
264264
},
265265
},
266-
'.swc.js': {
267-
module: '@swc/register',
268-
register: function (hook, config) {
269-
config = config || {
270-
only: [endsInSwcJs],
271-
ignore: [isNodeModules],
272-
jsc: {
273-
parser: {
274-
syntax: 'ecmascript',
266+
'.swc.js': [
267+
{
268+
module: '@swc-node/register',
269+
register: function (mod, config) {
270+
config = config || {
271+
only: [endsInSwcJs],
272+
ignore: [isNodeModules],
273+
jsc: {
274+
parser: {
275+
syntax: 'ecmascript',
276+
},
275277
},
276-
},
277-
module: {
278-
type: 'commonjs',
279-
},
280-
};
278+
module: {
279+
type: 'commonjs',
280+
},
281+
};
281282

282-
hook(
283-
Object.assign({}, config, {
284-
extensions: '.js',
285-
})
286-
);
283+
mod.register(
284+
Object.assign({}, config, {
285+
extensions: '.js',
286+
})
287+
);
288+
},
287289
},
288-
},
289-
'.swc.jsx': {
290-
module: '@swc/register',
291-
register: function (hook, config) {
292-
config = config || {
293-
only: [endsInSwcJsx],
294-
ignore: [isNodeModules],
295-
jsc: {
296-
parser: {
297-
syntax: 'ecmascript',
298-
jsx: true,
290+
{
291+
module: '@swc/register',
292+
register: function (hook, config) {
293+
config = config || {
294+
only: [endsInSwcJs],
295+
ignore: [isNodeModules],
296+
jsc: {
297+
parser: {
298+
syntax: 'ecmascript',
299+
},
299300
},
300-
},
301-
module: {
302-
type: 'commonjs',
303-
},
304-
};
301+
module: {
302+
type: 'commonjs',
303+
},
304+
};
305+
306+
console.log(hook)
307+
308+
hook(
309+
Object.assign({}, config, {
310+
extensions: '.js',
311+
})
312+
);
313+
},
314+
}
315+
],
316+
'.swc.jsx': [
317+
{
318+
module: '@swc-node/register',
319+
register: function (mod, config) {
320+
config = config || {
321+
only: [endsInSwcJsx],
322+
ignore: [isNodeModules],
323+
jsc: {
324+
parser: {
325+
syntax: 'ecmascript',
326+
jsx: true,
327+
},
328+
},
329+
module: {
330+
type: 'commonjs',
331+
},
332+
};
305333

306-
hook(
307-
Object.assign({}, config, {
308-
extensions: '.jsx',
309-
})
310-
);
334+
mod.register(
335+
Object.assign({}, config, {
336+
extensions: '.jsx',
337+
})
338+
);
339+
},
311340
},
312-
},
313-
'.swc.ts': {
314-
module: '@swc/register',
315-
register: function (hook, config) {
316-
config = config || {
317-
only: [endsInSwcTs],
318-
ignore: [isNodeModules],
319-
jsc: {
320-
parser: {
321-
syntax: 'typescript',
341+
{
342+
module: '@swc/register',
343+
register: function (hook, config) {
344+
config = config || {
345+
only: [endsInSwcJsx],
346+
ignore: [isNodeModules],
347+
jsc: {
348+
parser: {
349+
syntax: 'ecmascript',
350+
jsx: true,
351+
},
322352
},
323-
},
324-
module: {
325-
type: 'commonjs',
326-
},
327-
};
353+
module: {
354+
type: 'commonjs',
355+
},
356+
};
357+
358+
hook(
359+
Object.assign({}, config, {
360+
extensions: '.jsx',
361+
})
362+
);
363+
},
364+
}
365+
],
366+
'.swc.ts': [
367+
{
368+
module: '@swc-node/register',
369+
register: function (mod, config) {
370+
config = config || {
371+
only: [endsInSwcTs],
372+
ignore: [isNodeModules],
373+
jsc: {
374+
parser: {
375+
syntax: 'typescript',
376+
},
377+
},
378+
module: {
379+
type: 'commonjs',
380+
},
381+
};
328382

329-
hook(
330-
Object.assign({}, config, {
331-
extensions: '.ts',
332-
})
333-
);
383+
mod.register(
384+
Object.assign({}, config, {
385+
extensions: '.ts',
386+
})
387+
);
388+
},
334389
},
335-
},
336-
'.swc.tsx': {
337-
module: '@swc/register',
338-
register: function (hook, config) {
339-
config = config || {
340-
only: [endsInSwcTsx],
341-
ignore: [isNodeModules],
342-
jsc: {
343-
parser: {
344-
syntax: 'typescript',
345-
tsx: true,
390+
{
391+
module: '@swc/register',
392+
register: function (hook, config) {
393+
config = config || {
394+
only: [endsInSwcTs],
395+
ignore: [isNodeModules],
396+
jsc: {
397+
parser: {
398+
syntax: 'typescript',
399+
},
346400
},
347-
},
348-
module: {
349-
type: 'commonjs',
350-
},
351-
};
401+
module: {
402+
type: 'commonjs',
403+
},
404+
};
405+
406+
hook(
407+
Object.assign({}, config, {
408+
extensions: '.ts',
409+
})
410+
);
411+
},
412+
}
413+
],
414+
'.swc.tsx': [
415+
{
416+
module: '@swc-node/register',
417+
register: function (mod, config) {
418+
config = config || {
419+
only: [endsInSwcTsx],
420+
ignore: [isNodeModules],
421+
jsc: {
422+
parser: {
423+
syntax: 'typescript',
424+
tsx: true,
425+
},
426+
},
427+
module: {
428+
type: 'commonjs',
429+
},
430+
};
352431

353-
hook(
354-
Object.assign({}, config, {
355-
extensions: '.tsx',
356-
})
357-
);
432+
mod.register(
433+
Object.assign({}, config, {
434+
extensions: '.tsx',
435+
})
436+
);
437+
},
358438
},
359-
},
439+
{
440+
module: '@swc/register',
441+
register: function (hook, config) {
442+
config = config || {
443+
only: [endsInSwcTsx],
444+
ignore: [isNodeModules],
445+
jsc: {
446+
parser: {
447+
syntax: 'typescript',
448+
tsx: true,
449+
},
450+
},
451+
module: {
452+
type: 'commonjs',
453+
},
454+
};
455+
456+
hook(
457+
Object.assign({}, config, {
458+
extensions: '.tsx',
459+
})
460+
);
461+
},
462+
}
463+
],
360464
'.toml': {
361465
module: 'toml-require',
362466
register: function (hook, config) {
@@ -401,6 +505,29 @@ var extensions = {
401505
);
402506
},
403507
},
508+
{
509+
module: '@swc-node/register',
510+
register: function (mod, config) {
511+
config = config || {
512+
only: [endsInTs],
513+
ignore: [isNodeModules],
514+
jsc: {
515+
parser: {
516+
syntax: 'typescript',
517+
},
518+
},
519+
module: {
520+
type: 'commonjs',
521+
},
522+
};
523+
524+
mod.register(
525+
Object.assign({}, config, {
526+
extensions: '.ts',
527+
})
528+
);
529+
},
530+
},
404531
{
405532
module: '@swc/register',
406533
register: function (hook, config) {
@@ -474,6 +601,30 @@ var extensions = {
474601
);
475602
},
476603
},
604+
{
605+
module: '@swc-node/register',
606+
register: function (mod, config) {
607+
config = config || {
608+
only: [endsInTsx],
609+
ignore: [isNodeModules],
610+
jsc: {
611+
parser: {
612+
syntax: 'typescript',
613+
tsx: true,
614+
},
615+
},
616+
module: {
617+
type: 'commonjs',
618+
},
619+
};
620+
621+
mod.register(
622+
Object.assign({}, config, {
623+
extensions: '.tsx',
624+
})
625+
);
626+
},
627+
},
477628
{
478629
module: '@swc/register',
479630
register: function (hook, config) {

0 commit comments

Comments
 (0)