1+ import {
2+ resolve ,
3+ getSource ,
4+ } from 'react-transport-dom-webpack/node-loader' ;
5+
6+ export { resolve , getSource } ;
7+
18import babel from '@babel/core' ;
29
3- const options = {
10+ const babelOptions = {
411 babelrc : false ,
512 ignore : [ / \/ ( b u i l d | n o d e _ m o d u l e s ) \/ / ] ,
613 plugins : [
@@ -9,34 +16,15 @@ const options = {
916 ] ,
1017} ;
1118
12- const optionsCommonJS = {
13- ignore : [ / \/ ( b u i l d | n o d e _ m o d u l e s ) \/ / ] ,
14- presets : [ 'react-app' ] ,
15- plugins : [ '@babel/transform-modules-commonjs' ] ,
16- } ;
17-
1819export async function transformSource ( source , context , defaultTransformSource ) {
1920 const { format} = context ;
20- if ( format === 'module' || format === 'commonjs' ) {
21+ if ( format === 'module' ) {
2122 const opt = Object . assign (
2223 { filename : context . url } ,
23- format === 'commonjs' ? optionsCommonJS : options
24+ babelOptions
2425 ) ;
2526 const { code} = await babel . transformAsync ( source , opt ) ;
2627 return { source : code } ;
2728 }
28- return defaultTransformSource ( source , context ) ;
29- }
30-
31- export async function getSource ( url , context , defaultGetSource ) {
32- if ( url . endsWith ( '.client.js' ) ) {
33- const name = url ;
34- return {
35- source :
36- "export default { $$typeof: Symbol.for('react.module.reference'), name: " +
37- JSON . stringify ( name ) +
38- '}' ,
39- } ;
40- }
41- return defaultGetSource ( url , context , defaultGetSource ) ;
29+ return defaultTransformSource ( source , context , defaultTransformSource ) ;
4230}
0 commit comments