javascript-obfuscator / javascript-obfuscator/react-native-obfuscating-transformer

Missing "babylon" and other dependencies?

Aperta
#24 14 commenti 5 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
TypeScript
Stelle
211
Fork
102
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I am using this in a RN 0.61.5 project, and I've installed the project with:

```
npm install react-native-obfuscating-transformer --save-dev
```

When running `npx react-native start`, I get this error:

```
Loading dependency graph...Failed to construct transformer: Error: Cannot find module 'babylon'
Require stack:
-/node_modules/react-native-obfuscating-transformer/dist/getMetroTransformer.js
-/node_modules/react-native-obfuscating-transformer/dist/obfuscatingTransformer.js
-/node_modules/react-native-obfuscating-transformer/dist/index.js
-/transformer.js
-/node_modules/metro/src/JSTransformer/worker.js
-/node_modules/metro/src/DeltaBundler/Transformer/getTransformCacheKey.js
-/node_modules/metro/src/DeltaBundler/Transformer.js
-/node_modules/metro/src/Bundler.js
-/node_modules/metro/src/IncrementalBundler.js
-/node_modules/metro/src/index.js
-/node_modules/react-native/node_modules/@react-native-community/cli/build/tools/loadMetroConfig.js
-/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/runServer.js
-/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/server.js
-/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/index.js
-/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js
-/node_modules/react-native/cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:973:15)
at Function.Module._load (internal/modules/cjs/loader.js:855:27)
at Module.require (internal/modules/cjs/loader.js:1033:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (/node_modules/react-native-obfuscating-transformer/dist/getMetroTransformer.js:6:15)
at Module._compile (internal/modules/cjs/loader.js:1144:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
at Module.load (internal/modules/cjs/loader.js:993:32)
at Function.Module._load (internal/modules/cjs/loader.js:892:14)
at Module.require (internal/modules/cjs/loader.js:1033:19)
```

After running `npm i babylon --save-dev`, I get:

```
Loading dependency graph...Failed to construct transformer: Error: Cannot find module 'babel-traverse'
Require stack:
- /node_modules/react-native-obfuscating-transformer/dist/getMetroTransformer.js
- /node_modules/react-native-obfuscating-transformer/dist/obfuscatingTransformer.js
- /node_modules/react-native-obfuscating-transformer/dist/index.js
- /transformer.js
- /node_modules/metro/src/JSTransformer/worker.js
- /node_modules/metro/src/DeltaBundler/Transformer/getTransformCacheKey.js
- /node_modules/metro/src/DeltaBundler/Transformer.js
- /node_modules/metro/src/Bundler.js
- /node_modules/metro/src/IncrementalBundler.js
- /node_modules/metro/src/index.js
- /node_modules/react-native/node_modules/@react-native-community/cli/build/tools/loadMetroConfig.js
- /node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/runServer.js
- /node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/server.js
- /node_modules/react-native/node_modules/@react-native-community/cli/build/commands/index.js
- /node_modules/react-native/node_modules/@react-native-community/cli/build/index.js
- /node_modules/react-native/cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:973:15)
at Function.Module._load (internal/modules/cjs/loader.js:855:27)
at Module.require (internal/modules/cjs/loader.js:1033:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (/node_modules/react-native-obfuscating-transformer/dist/getMetroTransformer.js:7:24)
at Module._compile (internal/modules/cjs/loader.js:1144:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
at Module.load (internal/modules/cjs/loader.js:993:32)
at Function.Module._load (internal/modules/cjs/loader.js:892:14)
at Module.require (internal/modules/cjs/loader.js:1033:19)
```

My `transformer.js` is:

```js
const obfuscatingTransformer = require("react-native-obfuscating-transformer");

module.exports = obfuscatingTransformer({
/* options */
});
```

And my Metro Config:

```js
module.exports = {
transformer: {
babelTransformerPath: require.resolve("./transformer"),
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
```

I see that Babylon is part of the dependencies: https://github.com/javascript-obfuscator/react-native-obfuscating-transformer/blob/master/package.json#L14 – but then again, there seem to be duplicates?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia confrontando le dipendenze dichiarate in package.json con i moduli richiesti da dist/getMetroTransformer.js, usando come contesto la configurazione indicata di React Native 0.61.5 e Metro. Riproduci il fallimento con l’entry point transformer.js mostrato; il lavoro è completato quando il transformer si avvia senza errori relativi a moduli mancanti come babylon o babel-traverse.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
react-native, typescript
Ambito
build-system, tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.