2

I have a very basic question regarding ReactJS and pretty much between being beginner and intermediate.

I have designed my web application UI in webflow and now developing the frontend application in ReactJS.

So, now I have two JS files called mordenizr.js and webflow.js which I have to import in to my ReactJS component and pages JSX files. I wanted to know How could I import external or custom JavaScript files like these in to ReactJS and they are in plain/obfuscated/minified JS and not in ES6 format.

PS: I have created the project using create-react-app so not able to change or see webpack & babel configuration too

Thank you.

Regards,

Rohit

3 Answers 3

3

I don't see why import 'path/to/mordenizr' and import 'path/to/webflow' wouldn't just work.

After all, javascript files (even "plain/obfuscated/minified" ones) are valid ES6, so webpack should be able to import them like normal.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, yes it is importing but gives out error but when I dissected further, the error seems to be from the JS file and had to exclude it.
1

It does not matter whether these files are ES6 format or not, import 'mordenizr' should work in either case. The reason for this is that when Webpack transpiles your ES6 files, imports will get back to require format.

1 Comment

Thank you and yes the error is in JS file which works fine with normal HTML file but when imported in ReactJS then the error comes up. Had to exclude it.
0

use ["babel-plugin-import": "^1.0.1"] https://github.com/ant-design/babel-plugin-import for webpack

example:

plugins: ['transform-runtime','transform-decorators-legacy',['import', {
      libraryName: 'antd',
      style: 'css',
    }]]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.