Reputation: 141
I know that there is much questions with this title
But I have this one
SCRIPT1003: Expected ':' (1,78)
When launch web site
I use webpack and typescript at my project
Here is tsconfig
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"typeRoots": [
"./node_modules/@types"
],
"types": [ "jquery", "accounting","js-cookie" ],
"lib": ["es6", "dom"],
"allowSyntheticDefaultImports": true,
"module": "es6",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
},
"exclude": [
"**/*.spec.ts",
"node_modules",
"vendor",
"public"
],
"compileOnSave": false
}
Here is enviroment.js for webpack
const { environment } = require("@rails/webpacker");
const { resolve } = require("path");
const webpack = require("webpack");
const typescript = require("./loaders/typescript");
const HoneybadgerSourceMapPlugin = require("@honeybadger-io/webpack");
const revision = process.env.GIT_COMMIT || "master";
const apiKey = "***********";
const assetsUrl = "*/packs";
environment.plugins.prepend("Provide", new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
jquery: "jquery",
"window.Tether": "tether",
})
);
if (process.env.NODE_ENV === "production") {
environment.plugins.prepend(
"HoneybadgerSourceMap",
new HoneybadgerSourceMapPlugin({
apiKey: apiKey,
assetsUrl: assetsUrl,
silent: false,
ignoreErrors: false,
revision: revision
})
);
}
const config = environment.toWebpackConfig();
config.resolve.alias = {
jquery: "jquery/src/jquery",
};
config.externals = {
gon: "gon"
};
environment.loaders.get("sass").use.find((item) => item.loader === "sass-loader").options.includePaths = [resolve("app", "javascript", "themes")];
environment.loaders.append("typescript", typescript);
module.exports = environment;
Row (1,78) code
var o = e[i] ={
i,
l: !1,
exports :{}
};
But it seems to be autogenerated code of webpack I guess.
Where can be trouble and how I can fix this problem?
Upvotes: 0
Views: 897
Reputation: 1090
a few years too late, I guess, but I encountered this bug as well.
The solution is to add
if (environment.plugins.getIndex('UglifyJs') !== -1) {
const plugin = environment.plugins.get('UglifyJs');
plugin.options.uglifyOptions.ecma = 5;
}
to your environment.js
hope it helps somebody
here I found the solution: https://github.com/rails/webpacker/issues/1235
Upvotes: 1