rollup / stream Goto Github PK
View Code? Open in Web Editor NEW๐ฃ Stream Rollup build results
License: MIT License
๐ฃ Stream Rollup build results
License: MIT License
I am trying to use this module but it seems to have an issue with the options object. Even though I am providing one, it is returning Error: You must supply an options object. Please see report below.
gulpfile.js
function bundle() {
const options = {input : "src/main.js"}
return rollupStream(options)
.pipe(source("bundle.js"))
.pipe(dest("dist"))
}
exports.default = series(bundle);
run using gulp CLI
Bundling works without issue
Error: You must supply an options object
at getOutputOptionsAndPluginDriver (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/rollup/dist/shared/rollup.js:23604:15)
at handleGenerateWrite (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/rollup/dist/shared/rollup.js:23587:74)
at Object.generate (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/rollup/dist/shared/rollup.js:23548:20)
at build (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/@rollup/stream/dist/index.js:10:37)
Load @rollup/stream via require in new node
I did not isolate the problem since to me it looks pretty self-explanatory. But I may be mistaken and maybe the problem is even somehow in my code. So if you don't see the problem, please let me know and I'll try to isolate it.
Script is loaded
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /my/path/node_modules/rollup/dist/es/rollup.browser.js
require() of ES modules is not supported.
require() of /my/path/node_modules/rollup/dist/es/rollup.browser.js from /my/path/node_modules/@rollup/stream/dist/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename rollup.browser.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /my/path/node_modules/rollup/dist/es/package.json.
The example in the readme
import rollupStream from '@rollup/stream';
import gulp from 'gulp';
import terser from 'gulp-terser';
import source from 'vinyl-source-stream';
gulp.task('rollup', () => {
const options = { input: 'src/index.js' };
return rollupStream(options)
.pipe(source('bundle.js'))
.pipe(terser({ keep_fnames: true, mangle: false }))
.pipe(gulp.dest('dist'));
});
Causes an error Error: You must supply an options object
.
I fixed it by setting the output
import rollupStream from '@rollup/stream';
import gulp from 'gulp';
import terser from 'gulp-terser';
import source from 'vinyl-source-stream';
gulp.task('rollup', () => {
const options = { input: 'src/index.js', output: { format: 'cjs' } };
return rollupStream(options)
.pipe(source('bundle.js'))
.pipe(terser({ keep_fnames: true, mangle: false }))
.pipe(gulp.dest('dist'));
});
Developers who want to use the latest Rollup.
Update this for support with the latest Rollup (am I using this template right? ๐ ).
I don't know for sure that this isn't compatible with the latest Rollup, but I do note that Rollup 2.x violates this package's peer dependencies.
Hopefully context on this might be fresh given that this package is only 3 months old itself.
If you're seeing the output plugin warnings, the issue is fixed on the master branch but hasn't been pushed to npm yet.
I made a temporary workaround repo at download13/stream#v1.0.1
You can use it with npm install github:download13/stream#v1.0.1
Feel free to delete this when no longer relevant. Wasn't going to make another thread, but #8 was locked.
I'm using Rollup to bundle node dependencies specifically (not an entire app), and to do that efficiently it is useful to define multiple named entry points in a single config. With this approach, dependencies of dependencies which are sometimes shared between dependencies and thus can benefit from having multiple entry points that are evaluated together are also efficiently output as separate chunks as necessary via code splitting. The current examples, however, don't appear to support this output well since with them it seems like I can only have one file output and I need to know what it's called. To be able to do this efficiently, I believe that I need to have a mode for this plugin in which it wraps the files in Vinyl streams itself to provide multiple file outputs and preserve the names of those files.
The reason I'm not using gulp-rollup for this is that it seems to imply that I'd need to load every file that Rollup might need in gulp.src
, which seems inefficient, particularly because I'd ideally also want to avoid pulling in dev dependencies. I could maybe avoid providing any source files at all using this option, but that seems to be discouraged ๐คฃ
The rollup.config.js
that I'm currently using for this is below:
var replace = require('@rollup/plugin-replace');
var nodeResolve = require('@rollup/plugin-node-resolve');
var commonjs = require('@rollup/plugin-commonjs');
var babel = require('@rollup/plugin-babel');
var config = {
// the entry points for each item to bundle
input: {
'@date-io/moment': './node_modules/@date-io/moment/build/index.js'
'@material-ui/core': './node_modules/@material-ui/core/esm/index.js',
'@material-ui/lab/Autocomplete': './node_modules/@material-ui/lab/esm/Autocomplete/index.js',
'@material-ui/pickers': './node_modules/@material-ui/pickers/index.js',
'react': './node_modules/react/index.js',
'react/jsx-runtime': './node_modules/react/jsx-runtime.js',
'react/jsx-dev-runtime': './node_modules/react/jsx-dev-runtime.js',
'react-dom': './node_modules/react-dom/index.js',
'react-infinite-scroll-hook': './node_modules/react-infinite-scroll-hook/dist/index.js',
'react-merge-refs': './node_modules/react-merge-refs/dist/index.js'
'redux': './node_modules/redux/es/redux.js',
'react-redux': './node_modules/react-redux/es/index.js',
'redux-thunk': './node_modules/redux-thunk/es/index.js',
},
plugins: [
// replace node environment variables with appropriate values
replace({
preventAssignment: true,
values: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}
}),
// resolve named dependencies using node resolution rules
nodeResolve.nodeResolve({
browser: true
}),
// convert CommonJS modules to ES6 so Rollup will understand them
commonjs(),
// use babel to read and transpile modules, which may contain stuff like JSX
babel.babel({
babelHelpers: 'bundled',
extensions: [
'.js',
'.jsx'
]
})
],
output: {
// prefix dependency chunk bundles with __chunk_ to prevent conflicts
chunkFileNames: '__chunk_[name]/js/index.js',
// output all entry point bundles as AMD modules to js/index.js under the module's path
entryFileNames: '[name]/js/index.js',
// output modules in AMD format - our codebase is old and we'd like to eventually move
// away from this but we can't yet
format: 'amd',
// use ES interop
interop: 'auto'
}
};
// reference entry point dependencies by name rather than relative path
config.external = Object.keys(config.input);
module.exports = config;
It would be nice if this plugin offered an option to provide multiple chunks from Rollup as separate outputs in a format that's easy to consume since it seems like such output isn't available in the current version. I'm interested in potentially contributing a change that accomplishes this goal back to the main repository if this is a feature that maintainers are interested in adding or possibly documentation that shows how to use this plugin to accomplish such a goal if this feature already exists and I missed it.
I've put together a proposed implementation at master...reubenrybnik:output-vinyl-stream that is comprised of an optional flag which when specified causes this plugin's output to be changed to a Vinyl object stream to which the separate named files provided by Rollup are written. I'm currently using this implementation in a private commercial repository. This works for my use case but may not be the best implementation of this feature from maintainers' perspective, and I'm happy to discuss potential alternatives in that case.
If this approach is accepted, I believe my current proposed implementation of adding an option to switch to this output mode and making the Vinyl dependencies optional would make this a non-breaking change. However, I'm interested in knowing maintainers' views on whether it might be better to move away from the current pattern of using vinyl-source-stream
to convert the output to a single Vinyl item. In particular, I'm not sure whether there are any use cases in which this output is not immediately converted to Vinyl or whether maintainers are interested in supporting such use cases. I'm also interested in views on whether it would be better to switch to this mode using an option as in my current implementation or whether it might be better to provide a separate function property off of the main export instead (i.e. something like webpackStream.vinyl(config)
instead of webpackStream(config, { outputVinyl: true })
). I'd also welcome any other feedback you'd like to provide on this approach.
Thanks in advance for your consideration of this request!
Rollup 3 was just released last week, so this would be useful for developers who want to use the new version.
The current version of rollup/stream requires rollup 2.x as a peer dependency, but now that rollup 3 has been released, it would be useful to have a version of rollup/stream that supports it. The current version might still work with rollup 3 (I haven't tried it, so I'm not sure), but it might also have unintended consequences (especially with some of the deprecated/removed config/plugin options in rollup 3).
I realise it might be early days and you haven't had the chance to update the package yet, but I'd love to know if there are plans to support rollup 3 soon. I'd be happy to help testing/updating (if necessary) the package with rollup 3 if you want/need.
Thank you!
How can @rollup/stream be used by Gulp and use its built-in sourcemaps ability?
You are running Gulp watch so it runs rollup every time you save. You make a small change to one of the files and save. Instead of waiting for Rollup to recalculate the entire package bundle from scratch, it can improve performance by using data from the last bundle to only recalculate what is different.
The old rollup-stream
plugin supported a cache
option that allowed bundling performance to be drastically faster by only recalculating what had changed.
You can see an example of how the cache
option was used in this example:
https://github.com/Dan503/gulp-file-loader/blob/master/README.md#rollup-in-gulp-4
If it was capable of self-caching without any extra code, that would be even better.
If this has already been implemented then documenting it would be helpful.
If not, this is an important feature that most Gulp users would benefit greatly from.
I am trying to use this module but it seems to have an issue with the options object. Even though I am providing one, it is returning Error: You must supply an options object. Please see report below.
Minimal repository reproduction: https://github.com/Liam-OShea/RollupIssueReproduction
Bundling works without issue
Error: You must supply an options object
at getOutputOptionsAndPluginDriver (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/rollup/dist/shared/rollup.js:23604:15)
at handleGenerateWrite (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/rollup/dist/shared/rollup.js:23587:74)
at Object.generate (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/rollup/dist/shared/rollup.js:23548:20)
at build (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/@rollup/stream/dist/index.js:10:37)
Run a rollup build using this plugin, with plugins specified in the Rollup config, e.g.
plugins: [
rollupResolve(),
rollupBabel({
exclude: 'node_modules/**',
presets: [
['@babel/preset-env', {modules: false}],
['@babel/preset-react', {modules: false, development: isDev}]
],
plugins: ['@babel/plugin-proposal-class-properties'],
babelHelpers: 'bundled'
}),
commonJs({
include: 'node_modules/**',
ignore: ['conditional-runtime-dependency']
})
]
It builds correctly, but lots of errors appear like the following:
The "buildStart" hook used by the output plugin node-resolve is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
These errors shouldn't appear.
As above.
The NPM package doesn't appear to match the code shown here: https://github.com/rollup/stream/blob/master/src/index.ts
Specifically, in the version in my local node_modules folder I see the following line:
const { output } = await bundle.generate(options);
If I change it to match the version hosted here (by only supplying the output options) it works correctly:
const { output } = await bundle.generate(options.output);
I'm receiving some messages bellow when using some Rollup plugins (rollup-plugin-babel, @rollup/plugin-commonjs and @rollup/plugin-node-resolve).
The "resolveId" hook used by the output plugin babel is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
The "load" hook used by the output plugin babel is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
The "transform" hook used by the output plugin babel is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
The "buildStart" hook used by the output plugin node-resolve is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
The "resolveId" hook used by the output plugin node-resolve is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
The "load" hook used by the output plugin node-resolve is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
The "buildStart" hook used by the output plugin commonjs is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
The "resolveId" hook used by the output plugin commonjs is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
The "load" hook used by the output plugin commonjs is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
The "transform" hook used by the output plugin commonjs is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
My code:
...
return rollupStream({
input: 'src/test.js',
cache,
plugins: [
babel({
presets: [ [ '@babel/preset-env', { modules: false } ] ],
exclude: 'node_modules/**',
babelrc: false
}),
resolve(),
commonjs()
],
...
Apparently the plugins are working, but they are displaying these messages.
Please, can help me how to solve?
Thanks!
Not sure if this is rollup/stream or rollup problem.
gulp-sourcemaps
has some deprecated dependencies (convert-source-map
), but they don't look like they are at fault here.
Configuring rollup sourcemap:true gives error.
SyntaxError: Unexpected token in JSON at position 0
Changing to sourcemap:'inline' works.
Place the below 3 files in an empty project.
Install the deps:
npm install --save-dev {gulp,gulp-sourcemaps,@rollup/stream,@rollup/plugin-babel,@rollup/plugin-commonjs,@rollup/plugin-node-resolve,vinyl-source-stream,vinyl-buffer}@latest
Run it: node ./rollup-repro.js
You should observe the error (new since rollup@3, issue wasn't present in the last 2.x).
SyntaxError: Unexpected token in JSON at position 0
at JSON.parse (<anonymous>)
at new Converter (/tmp/sample-project/node_modules/convert-source-map/index.js:76:48)
at Object.exports.fromComment (/tmp/sample-project/node_modules/convert-source-map/index.js:155:10)
at Object.exports.fromSource (/tmp/sample-project/node_modules/convert-source-map/index.js:167:22)
at _getInlineSources (/tmp/sample-project/node_modules/gulp-sourcemaps/src/init/index.internals.js:85:27)
at Object.loadMaps (/tmp/sample-project/node_modules/gulp-sourcemaps/src/init/index.internals.js:24:5)
at DestroyableTransform.sourceMapInit [as _transform] (/tmp/sample-project/node_modules/gulp-sourcemaps/src/init/index.js:41:30)
at DestroyableTransform.Transform._read (/tmp/sample-project/node_modules/readable-stream/lib/_stream_transform.js:184:10)
...
Edit the rollup config to change sourcemap: true,
to sourcemap: 'inline',
Run again, the error should disappear.
.js.map
files are streamed out raw as "assets"...or maybe this is gulp-sourcemaps fault?
I inserted some dumb logging up and down the error stack to see what was going on with the data. What I saw is that we end up with the sourcemap twice. Once as a base64 encoded inline comment and appended to that directly is an unencoded .js.map
file contents. When that is attempted to be extracted, it blows up of course. Switching to inline mode removes the presence of the .js.map
files being output and so the problem disappears.
Note the end where the base64 inline sourcemap ends and we jump right into a javascript object from the non-inline sourcemap file that was emitted as an "asset".
...0FBQzs7Ozs7OyJ9{"version":3,"file":"some-app.js",...
{
path: '',
map: null,
content: '(function () {\n' +
" 'use strict';\n" +
'\n' +
' var urlDecode = {\n' +
' urlDecode: urlDecode$1,\n' +
' encodeURIComponent: encodeURIComponent,\n' +
' decodeURIComponent: decodeURIComponent\n' +
' };\n' +
' function encodeURIComponent(str) {\n' +
' return window.encodeURIComponent(str);\n' +
' }\n' +
' function decodeURIComponent(str) {\n' +
' return window.decodeURIComponent(str);\n' +
' }\n' +
' function urlDecode$1(url) {\n' +
' var limit = 5,\n' +
' i,\n' +
' origUrl = url;\n' +
' url = url.trim();\n' +
' if (!url) return origUrl;\n' +
'\n' +
" // don't try to decode stuff that doesn't start with http\n" +
" if (url.toLowerCase().indexOf('http') !== 0) return url;\n" +
' for (i = 0; i <= limit; i++) {\n' +
" if (url.toLowerCase().indexOf('http://') == 0 || url.toLowerCase().indexOf('https://') == 0) {\n" +
' return url;\n' +
' }\n' +
' try {\n' +
' url = window.decodeURIComponent(url);\n' +
' } catch (e) {\n' +
' return origUrl;\n' +
' }\n' +
' }\n' +
' return origUrl;\n' +
' }\n' +
'\n' +
" var aUrl = 'http%25253A%25252F%25252Fexample.com%25253Ffoo%2525252Cbar%25253Dhello%2525252Cworld';\n" +
" console.log('Hello world: ' + urlDecode(aUrl));\n" +
'\n' +
'})();\n' +
'//# sourceMappingURL=some-app.js.map\n' +
'\n' +
`//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic29tZS1hcHAuanMiLCJzb3VyY2VzIjpbInNyYy9qcy9saWIvdXJsLWRlY29kZS5qcyIsInNyYy9qcy9zb21lLWFwcC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcblxuXG5leHBvcnQgZGVmYXVsdCB7XG4gICAgdXJsRGVjb2RlLFxuICAgIGVuY29kZVVSSUNvbXBvbmVudCxcbiAgICBkZWNvZGVVUklDb21wb25lbnQsXG59O1xuXG5leHBvcnQgZnVuY3Rpb24gZW5jb2RlVVJJQ29tcG9uZW50IChzdHIpIHtcbiAgICByZXR1cm4gd2luZG93LmVuY29kZVVSSUNvbXBvbmVudChzdHIpO1xufVxuZXhwb3J0IGZ1bmN0aW9uIGRlY29kZVVSSUNvbXBvbmVudCAoc3RyKSB7XG4gICAgcmV0dXJuIHdpbmRvdy5kZWNvZGVVUklDb21wb25lbnQoc3RyKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHVybERlY29kZSh1cmwpIHtcbiAgICB2YXIgbGltaXQgPSA1LCBpLFxuICAgICAgICBvcmlnVXJsID0gdXJsO1xuXG4gICAgdXJsID0gdXJsLnRyaW0oKTtcblxuICAgIGlmICghdXJsKSByZXR1cm4gb3JpZ1VybDtcblxuICAgIC8vIGRvbid0IHRyeSB0byBkZWNvZGUgc3R1ZmYgdGhhdCBkb2Vzbid0IHN0YXJ0IHdpdGggaHR0cFxuICAgIGlmICh1cmwudG9Mb3dlckNhc2UoKS5pbmRleE9mKCdodHRwJykgIT09IDApIHJldHVybiB1cmw7XG5cbiAgICBmb3IgKGk9MDsgaSA8PSBsa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E1BQUFBLEdBQUcsR0FBR0QsTUFBTSxDQUFDRixrQkFBa0IsQ0FBQ0csR0FBRyxDQUFDLENBQUE7U0FDdkMsQ0FDRCxPQUFPTyxDQUFDLEVBQUU7SUFDTixNQUFBLE9BQU9KLE9BQU8sQ0FBQTtJQUNsQixLQUFBO0lBQ0osR0FBQTtJQUNBLEVBQUEsT0FBT0EsT0FBTyxDQUFBO0lBQ2xCOztJQ3JDQSxJQUFNSyxJQUFJLEdBQUcsc0ZBQXNGLENBQUE7SUFFbkdDLE9BQU8sQ0FBQ0MsR0FBRyxDQUFDLGVBQWUsR0FBR2YsU0FBUyxDQUFDYSxJQUFJLENBQUMsQ0FBQzs7Ozs7OyJ9{"version":3,"file":"some-app.js","sources":["src/js/lib/url-decode.js","src/js/some-app.js"],"sourcesContent":["\\n\\n\\nexport default {\\n urlDecode,\\n encodeURIComponent,\\n decodeURIComponent,\\n};\\n\\nexport function encodeURIComponent (str) {\\n return window.encodeURIComponent(str);\\n}\\nexport function decodeURIComponent (str) {\\n return window.decodeURIComponent(str);\\n}\\n\\nexport function urlDecode(url) {\\n var limit = 5, i,\\n origUrl = url;\\n\\n url = url.trim();\\n\\n if (!url) return origUrl;\\n\\n // don't try to decode stuff that doesn't start with http\\n if (url.toLowerCase().indexOf('http') !== 0) return url;\\n\\n for (i=0; i <= limit; i++ ) {\\n if (url.toLowerCase().indexOf('http://') == 0\\n || url.toLowerCase().indexOf('https://') == 0) {\\n return url;\\n }\\n try {\\n url = window.decodeURIComponent(url); \\n }\\n catch (e) {\\n return origUrl;\\n }\\n }\\n return origUrl;\\n}","\\nimport urlDecode from './lib/url-decode.js';\\n\\nconst aUrl = 'http%25253A%25252F%25252Fexample.com%25253Ffoo%2525252Cbar%25253Dhello%2525252Cworld';\\n\\nconsole.log('Hello world: ' + urlDecode(aUrl));"],"names":["urlDecode","encodeURIComponent","decodeURIComponent","str","window","url","limit","i","origUrl","trim","toLowerCase","indexOf","e","aUrl","console","log"],"mappings":";;;AA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GAAG,sFAAsF,CAAA;IAEnGC,OAAO,CAACC,GAAG,CAAC,eAAe,GAAGf,SAAS,CAACa,IAAI,CAAC,CAAC;;;;;;"}`,
preExistingComment: null
}
import gulp from 'gulp';
import sourcemaps from 'gulp-sourcemaps';
import path from 'node:path';
import rollupStream from '@rollup/stream';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import babel from '@rollup/plugin-babel';
import commonJs from '@rollup/plugin-commonjs';
import resolveNodeModules from '@rollup/plugin-node-resolve';
const babelConfig = {
babelHelpers: 'bundled',
presets: [
[
'@babel/preset-env',
{
corejs: {
version: 3
},
useBuiltIns: 'entry',
targets: '> 0.1%',
}
]
]
};
function rollup (entryPath, destDir, exportName) {
const entryFileName = path.basename(entryPath),
rollupConfig = {
input: entryPath,
output: {
format: 'iife',
name: exportName ? exportName : '_crCus', // the output global name.
sourcemap: true,
},
plugins: [
resolveNodeModules({browser:true}),
commonJs(),
babel(babelConfig),
],
};
return rollupStream(rollupConfig)
.pipe(source(entryFileName))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
// terser or whatever here
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(destDir));
}
rollup('./some-app.js', '/tmp', '_someApp');
import urlDecode from './url-decode.js';
const aUrl = 'http%25253A%25252F%25252Fexample.com%25253Ffoo%2525252Cbar%25253Dhello%2525252Cworld';
console.log('Hello world: ' + urlDecode(aUrl));
export default {
urlDecode,
encodeURIComponent,
decodeURIComponent,
};
export function encodeURIComponent (str) {
return window.encodeURIComponent(str);
}
export function decodeURIComponent (str) {
return window.decodeURIComponent(str);
}
export function urlDecode(url) {
var limit = 5, i,
origUrl = url;
url = url.trim();
if (!url) return origUrl;
// don't try to decode stuff that doesn't start with http
if (url.toLowerCase().indexOf('http') !== 0) return url;
for (i=0; i <= limit; i++ ) {
if (url.toLowerCase().indexOf('http://') == 0
|| url.toLowerCase().indexOf('https://') == 0) {
return url;
}
try {
url = decodeURIComponent(url);
}
catch (e) {
return origUrl;
}
}
return origUrl;
}
I expect both inline/non-inline sourcemap configs to work.
I expect the examples in the README to work.
See above.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.