babeljs

Build React components with Gulp, Browserify and Babel

跟風遠走 提交于 2019-12-23 18:57:33
问题 I've created a React component and I want to distribute a built-in version (built with gulp) of this component, so in gulpfile.js I have: var gulp = require('gulp'); var browserify = require('browserify'); var babelify = require('babelify'); var source = require('vinyl-source-stream'); gulp.task('build-js', function() { return browserify('./src/Foo.js') .transform(babelify) .bundle() .pipe(source('bundle.js')) .pipe(gulp.dest('./dist')); }); gulp.task('build', ['build-js']); In .babelrc : {

How to optionally process code in node_modules with babel-loader in webpack?

旧街凉风 提交于 2019-12-23 18:38:55
问题 This is a follow up from this answer. I have some 3rd party code (react components) that I bundle as ES modules (using the pkg.module entry point). This works great (you get module concatenation and tree shaking), but the included code isn't transpiled with babel because, following most config examples, I exclude node_modules in the babel-loader section of my webpack config like this: { ... module: { rules: [ { exclude: /(node_modules)/, use: { loader: 'babel-loader', ... } } ] }, ... } So, I

atom how to change default syntax highlighting for .js files to language-babel

。_饼干妹妹 提交于 2019-12-23 13:19:06
问题 It's all in the title.. suddenly atom no longer defaults to language-babel for .js files and I'm not sure how to get back to the previous behaviour. update - current config.cson: "*": core: telemetryConsent: "no" editor: fontFamily: "Operator Mono Lig" "exception-reporting": userId: "a8f4cc72-fe9c-4093-b562-fcb344219d50" "language-dotenv": dotenvFileNames: [ ".env" ".env.schema" ] "linter-eslint": {} "linter-ui-default": {} "prettier-atom": formatOnSaveOptions: enabled: true

Why is node require cache filling up and leaking

萝らか妹 提交于 2019-12-23 13:12:21
问题 Im stress testing an API in loopback which is transpiled with Babel. However, during these longer "smoke" tests, we have seen the require cache in Heap analysis growing quite large (up to 1gb) and does not get GCd. I understand the require cache wont GC until the last reference is removed, but why would it continue to grow if Im calling the same set of methods over and over? Could this be an issue with Babel 6, or NodeJS 4.4.3? Here is a screen shot showing the heap dump 回答1: We were hitting

Optional Chaining not enabled ReactNative

帅比萌擦擦* 提交于 2019-12-23 12:51:05
问题 I am getting this error when running the android project in react react native. This is fresh install of react native version "react": "^16.3.1","react-native": "^0.57.1", It gives error of optional chaining. Can anyone please help me how to enable optional chaining in react native. Loading dependency graph, done. BUNDLE [android, dev] ....../index.js ▓▓▓▓▓▓▓▓▓▓░░░░░░ 64.3% (667/832)::ffff:127.0.0.1 - - [02/Oct/2018:04:30:46 +0000] "GET /index.delta?platform=android&dev=true&minify=false HTTP

Why does my arrow function have a prototype property?

眉间皱痕 提交于 2019-12-23 12:47:21
问题 As mention in document https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions Arrow functions do not have prototype property but when I run this on fiddle, why does it gives an object ? http://es6console.com/iwyii5vm/ Why it is giving a object? var Foo = () => {}; console.log(Foo.prototype); 回答1: If you run this code in a native ES6 engine, there will not be a prototype property for arrow functions. Example of native ES6: var Foo = () => {}; console.log(Foo

Dynamically choose class from string - “MyClassName” -> MyClassName [duplicate]

北城余情 提交于 2019-12-23 12:34:48
问题 This question already has answers here : Create object from string in JavasScript ECMAScript 6 (5 answers) Closed 3 years ago . I use babel.js traspiler to write ES6 code. I have a string containing class name. I want a class that I can instantiate. How? I tried: eval("MyClassName") -> :( window["MyClassName"] -> :( Any ideas? 回答1: You Can: Since with BabelJS you have to transpile to an ES5 module loader, it would be as simple as (depending on the module format you've specified at transpile

webpack require non-js content in jest unit-tests

白昼怎懂夜的黑 提交于 2019-12-23 12:08:03
问题 Recently I've converted one of my projects to webpack & babel. It is made out of knockout components. I'm running into a problem while running the unit-tests. If I have a file in the tests folder like import component from '../custom-options'; test('adds 1 + 2 to equal 3', () => { expect(3).toBe(3); }); The problem is that the component is a module which has a require of the sort var htmlString = require('./custom-options.html'); When I try to run the website itself it runs fine, as the raw

Grunt Babel Taking 6 Seconds Per File

a 夏天 提交于 2019-12-23 10:26:09
问题 I'm trying to use Babel in my grunt build process to transpile my .js project files from ES6 to ES5. I have a watch task watching my .js directory for changes and when changes are detected, I run the babel task. For some reason though, changing just one .js file takes anywhere between 6-10 seconds to complete. I have a feeling it's transpiling the entire project, but I'm not sure. My Gruntfile.js looks like this: grunt.initConfig({ watch: { babel: { files: ["<%= yeoman.app %>/scripts/**/*.js"

How to use Babel 6 external helpers in the browser?

风流意气都作罢 提交于 2019-12-23 09:51:28
问题 First the question: Where can I find the external-helpers.js script, or how can I build the external-helpers for Babel 6? In Babel 5.x, I was able to use the externalHelpers option, which required including external-helpers.js , which used to be in the babel-core package. Moving on to Babel 6, I see that external-helpers is now external-helpers-2 plugin. This does the job of including the relevant babelHelper calls in my transpiled code, but that is it; I need the actual helper definitions!