You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Script tags with relative url unexpected token < #577
Adding a script tag with a relative src throws SyntaxError: Unexpected token <
To reproduce, create-react-app then add this line to index.html: <script type="text/javascript" src="test.js"></script>
File should look like this:
<!doctype html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport" content="width=device-width, initial-scale=1"><linkrel="shortcut icon" href="./src/favicon.ico"><title>React App</title><scripttype="text/javascript" src="test.js"></script></head><body><divid="root"></div><!-- This HTML file is a template. If you open it directly in the browser, you will see an empty page. You can add webfonts, meta tags, or analytics to this file. The build step will place the bundled scripts into the <body> tag. To begin the development, run `npm start` in this folder. To create a production bundle, use `npm run build`. --></body></html>
npm start and chrome will throw index.js:1 Uncaught SyntaxError: Unexpected token <
What are you trying to do? This was never officially supported. It accidentally worked in versions before 0.4.0 but only worked in development.
Normally you should just import scripts instead in src/index.js. If there is some reason why this doesn't satisfy your use case, please describe it here so we can have a better idea of your use case and can address it in a future version. Thanks!
I'm using a module (js-ipfs-api) which requires fs shims to run in browser and would prefer not to eject. I'll host it remotely for now and wait for its webpack incompatibilities to be resolved.
Let's keep this open for now. Maybe we can configure Webpack to include more sensible shim for fs. I've seen this problem a couple of times and I think there was some solution.
Activity
gaearon commentedon Sep 5, 2016
What are you trying to do? This was never officially supported. It accidentally worked in versions before 0.4.0 but only worked in development.
Normally you should just
importscripts instead insrc/index.js. If there is some reason why this doesn't satisfy your use case, please describe it here so we can have a better idea of your use case and can address it in a future version. Thanks!Related: #573 #551.
nycoliver commentedon Sep 6, 2016
I'm using a module (js-ipfs-api) which requires fs shims to run in browser and would prefer not to eject. I'll host it remotely for now and wait for its webpack incompatibilities to be resolved.
gaearon commentedon Sep 6, 2016
Let's keep this open for now. Maybe we can configure Webpack to include more sensible shim for fs. I've seen this problem a couple of times and I think there was some solution.
cloudmu commentedon Sep 9, 2016
Related: #573
gaearon commentedon Sep 22, 2016
I drafted a proposal to solve this in #703. Unless we find some fatal flaws, it should come out in 0.5.0. Let me know what you think!
gaearon commentedon Sep 22, 2016
Closing as this is fixed, and will be released in 0.5.0.
gaearon commentedon Sep 23, 2016
This is now supported in 0.5.0.
Read about using the new
publicfolder.See also migration instructions and breaking changes in 0.5.0.