Is It Possible To Run Babel Without A Cdn And Node?
I want to use Babel, to be able to support some IE browsers in my web-application. I previously used Node and some cdn's in my project, but replaced it with local min.js files, and i want to keep it this way if possible.
So far i have downloaded the babel.min.js, and replaced this:
<script src="./src/index.js"></script>
With this:
<script src="./src/index.js" type="text/babel"></script>
This threw CORS errors in Chrome and Firefox, and it's still just showing a blank page in IE. When testing i'm just running the files locally, so this might not be an issue when deploying to the server, but that's not possible right now.
I was reading a bit about the config files, and the closest i got was that i might need to create a .babelrc file. But the documentation keeps mentioning using NPM and the package.json file, which i want to avoid.
So right now i can't seem to figure out if what i'm trying to achieve is even possible. If possible, i'm uncertain as to how to tell Babel which file to transpile.
The errors thrown are:
Access to XMLHttpRequest at 'file:///C:/src/index.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
and
GET file:///C://src/index.js net::ERR_FAILED Blockquote
enter code here
Answer
Running it all through a local server seemed to fix it, and made Babel work. So i guess it is possible, and i didn't need to create a config file.
For anyone curious as to how i did it, i used this guide: How do you set up a local testing server?
I will off course need to test if the performance can handle transpiling it on the go. Otherwise i will have to transpile it before deploying it to the webserver, like Jed mentioned.
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM