Comments (6)
If I run
-t [babelify --only \"./index.js\" browserify-shim]
and use es6import syntax I get an error within my imported shimmed dependency (polymer).
Because the --only
argument will only run babelify
on index.js
. Checking out that repo and running:
$ npm run babel-before
Works without a problem.
from babelify.
Hey @sebmck thanks for the response! I'm getting an error. The only way I can get it to run is without using babelify. The only reason it works is because I'm not using es6 imports in that repo 😿
For SEO:
function element(name, prototype) {
if (typeof name !== 'string') {
var script = prototype || document._currentScript;
prototype = name;
name = script && script.parentNode && script.parentNode.getAttribute ?
script.parentNode.getAttribute('name') : '';
if (!name) {
throw 'Element name could not be inferred.';
}
}
if (getRegisteredPrototype(name)) {
throw 'Already registered (Polymer) prototype for element ' + name;
}
// cache the prototype
registerPrototype(name, prototype);
// notify the registrar waiting for 'name', if any
notifyPrototype(name);
}
bundle-babel-before.js:3 Uncaught TypeError: Cannot set property 'esprima' of undefined
bundle-babel-after.js:6387 Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': Nodes of type 'HTML' may not be inserted inside nodes of type '#document'.
bundle-without-babel.js:10400 Uncaught TypeError: Cannot read property 'resolveDom' of undefined
from babelify.
@sebmck It's just apparent that it's a babilfy issue then because it works without babelify. That's why I wen't with --only
to stop babelify from processing polymer
.
from babelify.
@reggi You should be ignoring bower_components
anyway with:
$ browserify -t [babelify --ignore \"bower_components\" browserify-shim]
Since otherwise bower_components
will be unnecessarily transformed.
from babelify.
@reggi I took a quick look at your repo and es6-polymer-babel-index-shimmed.js
works with:
# backslashes for readability only
node ./node_modules/.bin/browserify ./index-es6.js \
-t [ babelify --ignore bower_components ] \
-t browserify-shim \
--debug \
> es6-polymer-babel-index-shimmed.js
You need to ignore bower_components
because since it's not node_modules
, browserify will apply the babelify transform to it. Also, transforms need to specified separately.
If you're curious about why polymer didn't like to get babeled, it's because it doesn't seem to work in strict mode. If you turn off that babel transform, it also works:
node ./node_modules/.bin/browserify ./index-es6.js \
-t [ babelify --blacklist strict ] \
-t browserify-shim \
--debug \
> es6-polymer-babel-index-shimmed.js
Though, it's more efficient to simply ignore bower_components
since you don't want it transformed at all.
PS: There is no --test
flag. You probably meant --debug
for source maps.
from babelify.
This seems resolved to me.
from babelify.
Related Issues (20)
- Babel 7 Stable Released HOT 8
- Bundling hyperhtml-element with browserify/babelify not working
- transform-arrow-functions being ignored for external packages? HOT 5
- TypeError: extensions.indexOf is not a function
- TypeError: Cannot read property 'canCompile' of undefined HOT 5
- How to get babelify && preset-env to convert 'const' HOT 3
- Boolean options fail (e.g. --compact true) HOT 1
- usage of babel/polyfills HOT 4
- Not working "Why aren't files in node_modules being transformed?" HOT 14
- Use a Bundler for Development? HOT 1
- tsify + babelify + browserify with threejs modules: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (9:0) HOT 17
- Is it possible to disable asyncToGenerator? HOT 2
- TypeError: Cannot read property 'arrayify' of undefined HOT 2
- Is this incompatible with Babel 7? HOT 3
- If I don't specify any Babel plugins or presets, what exactly should happen? HOT 6
- Continued problems with issue #103 ('import' and 'export' may appear only with 'sourceType: module') HOT 4
- How to use with globally installed browserify? HOT 1
- No source being transformed HOT 1
- babelify + gulp with threejs modules: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (9:0)
- 'import' and 'export' may appear only with 'sourceType: module' (14:0)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babelify.