RC.0 - Cannot import json - require is not defined

I’m trying to import a json file. Until beta.11 it works fine:

var config = require(‘./config.json’);

But now on RC.0 it compiles okay, but on the browser says:

Uncaught ReferenceError: require is not defined

What has changed?

I’m having a similar problem, may be related, with other imports like

on beta.11
import * as _ from ‘underscore’;

on RC.0
import _ from ‘underscore’;

What has changed about compilation?

The bundler. Used to be browserify, now is rollup. For your JSON issue, check out this.

It appears that the json rollup plugin is included by default as of ionic-app-scripts 0.0.28.

1 Like

I have the same problem here, can’t seem to import a json file as a module, event with rollup-plugin-json installed and used in rollup.config.js.

import config from ‘./app.config.json’;

error TS2307: Cannot find module ‘./app.config.json’.

Anybody else having this issue ?

1 Like

i’m having that problem too,