Giter Club home page Giter Club logo

Comments (12)

satya164 avatar satya164 commented on July 24, 2024

Customize the loader you get in defaults.module.rules to exclude your file.

https://github.com/callstack-io/haul/blob/master/docs/Configuration.md
https://webpack.js.org/configuration/module/#rule-exclude

from haul.

chandu0101 avatar chandu0101 commented on July 24, 2024

@satya164 thanks for reply

wepack.haul.js

var path = require('path')


module.exports = ({ platform },defaults) => ({
  entry: `./index.${platform}.js`,
   module: {
     ...defaults.module,
       rules: [
           ...defaults.module.rules,
                {
                  test: /\.js$/,
                  exclude: [/node_modules\/(?!react|@expo|haul)/,
                  path.resolve(__dirname, 'assets/scalajs-output-ios.js')
                  ],
                  use: {
                    loader: require.resolve('happypack/loader'),
                    query: { id: 'babel' },
                  },
                },

         ],
   }
});

index.ios.js

require("./assets/scalajs-output-ios.js")

yarn run haul start -- --platform ios

but build is struck at 20%

 INFO  Ready at http://localhost:8081

Haul is now bundling your React Native app, starting from:

/projectpath/index.ios.js

A fresh build may take longer than usual

[====                ] 20%

from haul.

satya164 avatar satya164 commented on July 24, 2024

you'll want to filter it out from defaults.module.rules too

from haul.

chandu0101 avatar chandu0101 commented on July 24, 2024

you'll want to filter it out from defaults.module.rules too

i didn't understand this fully,
but my scalajs-output-ios.js is already ES5 , it's redundant to pass it through babel again :s

from haul.

satya164 avatar satya164 commented on July 24, 2024

You already have this rule in defaults.module.rules, if you don't filter it, then you have two rules for js

from haul.

chandu0101 avatar chandu0101 commented on July 24, 2024

oh ok got you, so i have to filter defaults.module.rules before merging right ?

from haul.

chandu0101 avatar chandu0101 commented on July 24, 2024

@satya164 its good to provide some option to provide extra excludes and merge them in default .js rules ?

from haul.

grabbou avatar grabbou commented on July 24, 2024

I think in that case instead of merging your rules with default rules, you better providing your own set of rules and forgetting about ours at all. We export an array, so you can take whatever you want by index.

from haul.

satya164 avatar satya164 commented on July 24, 2024

I guess better not to rely on index since it'll break when if we add any loaders, but defaults.module.rules.filter before merging should be fine

from haul.

chandu0101 avatar chandu0101 commented on July 24, 2024

i think i don't know what i am doing here :( , with this following config , i see build going until 91%

webpack.haul.js

var path = require('path')


module.exports = ({ platform },defaults) => ({
  entry: `./index.${platform}.js`,
   module: {
     ...defaults.module,
       rules: [
           ...(defaults.module.rules.filter((obj) => {
           console.log(obj.test);
           obj.test != `/\.js$/` })),
              {
                   test: /\.js$/,
                   exclude: [/node_modules\/(?!react|@expo|haul)/,
                   path.resolve(__dirname, 'assets/scalajs-output-ios.js')],
                   use: {
                     loader: require.resolve('happypack/loader'),
                     query: { id: 'babel' },
                   },
                 },
         ],
   }
});

but in the end i am seeing bunch of following errors

ERROR in ./~/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactRef.js
Module parse failed: project_path/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactRef.js Unexpected token (17:12)
You may need an appropriate loader to handle this file type.
| var ReactOwner = require('ReactOwner');
| 
| import type { ReactInstance } from 'ReactInstanceType';
| import type { ReactElement } from 'ReactElementType';
| 
 @ ./~/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactReconciler.js 14:15-34
 @ ./~/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactUpdates.js
 @ ./~/react-native/Libraries/react-native/react-native-implementation.js
 @ ./assets/scalajs-output-ios.js
 @ ./index.ios.js
 @ multi ./~/haul-cli/src/utils/polyfillEnvironment.js ./index.ios.js

from haul.

grabbou avatar grabbou commented on July 24, 2024

On a side note - since this is Webpack - I believe a more efficient way would be to explicitly override loader for that particular require rather than adding it to exclude list.

Revert back you Haul config to what it used to be in the first commend and replace require with the following:

require("!!./assets/scalajs-output-ios.js")

The double exclamation mark will disable all preloaders and loaders for that particular call.

from haul.

chandu0101 avatar chandu0101 commented on July 24, 2024

@grabbou thanks for info , I don't know what added recently, its working fine now without any hacks.

from haul.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.